From 68337262c19aef67901c451f9f6416d97ec98023 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 12 Jul 2016 09:58:35 -0600 Subject: [PATCH 001/159] add EMS to .idd --- openstudiocore/resources/model/OpenStudio.idd | 322 ++++++++++++++++++ 1 file changed, 322 insertions(+) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 22c81aa026e..278425e884b 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26362,3 +26362,325 @@ OS:Meter:CustomDecrement, \begin-extensible A6; \field Output Variable or Meter Name +\group Energy Management System (EMS) + +OS:EnergyManagementSystem:Sensor, + \memo Declares EMS variable as a sensor + \memo a list of output variables and meters that can be reported are available after a run on + \memo the report (.rdd) or meter dictionary file (.mdd) if the Output:VariableDictionary + \memo has been requested. + \min-fields 3 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note This name becomes a variable for use in Erl programs + \note no spaces allowed in name + A3 , \field Output:Variable or Output:Meter Index Key Name + \type alpha + A4 ; \field Output:Variable or Output:Meter Name + \required-field + \type external-list + \external-list autoRDDvariableMeter + +OS:EnergyManagementSystem:Actuator, + \memo Hardware portion of EMS used to set up actuators in the model + \min-fields 4 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note This name becomes a variable for use in Erl programs + \note no spaces allowed in name + A3 , \field Actuated Component Unique Name + \required-field + \type alpha + A4 , \field Actuated Component Type + \required-field + \type alpha + A5 ; \field Actuated Component Control Type + \required-field + \type alpha + +OS:EnergyManagementSystem:ProgramCallingManager, + \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. + \memo Input EMS program. a program needs a name + \memo a description of when it should be called + \memo and then lines of program code for EMS Runtime language + \min-fields 3 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \reference ProgramNames + \note no spaces allowed in name + A3 , \field EnergyPlus Model Calling Point + \type choice + \key BeginNewEnvironment + \key AfterNewEnvironmentWarmUpIsComplete + \key BeginTimestepBeforePredictor + \key AfterPredictorBeforeHVACManagers + \key AfterPredictorAfterHVACManagers + \key InsideHVACSystemIterationLoop + \key EndOfZoneTimestepBeforeZoneReporting + \key EndOfZoneTimestepAfterZoneReporting + \key EndOfSystemTimestepBeforeHVACReporting + \key EndOfSystemTimestepAfterHVACReporting + \key EndOfZoneSizing + \key EndOfSystemSizing + \key AfterComponentInputReadIn + \key UserDefinedComponentModel + \key UnitarySystemSizing + A4 ; \field Program Name 1 + \begin-extensible + \required-field + \type object-list + \note no spaces allowed in name + \object-list ErlProgramNames + +OS:EnergyManagementSystem:Program, + \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. + \memo This input defines an Erl program + \memo Each field after the name is a line of EMS Runtime Language + \min-fields 2 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \reference ErlProgramNames + \note no spaces allowed in name + A3 ; \field Program Line 1 + \begin-extensible + \type alpha + \required-field + +OS:EnergyManagementSystem:Subroutine, + \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. + \memo This input defines an Erl program subroutine + \memo Each field after the name is a line of EMS Runtime Language + \min-fields 2 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \reference ErlProgramNames + \note no spaces allowed in name + A3 ; \field Program Line 1 + \begin-extensible + \type alpha + + OS:EnergyManagementSystem:GlobalVariable, + \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. + \memo Declares Erl variable as having global scope + \memo No spaces allowed in names used for Erl variables + \min-fields 1 + A1, \field Handle + \type handle + \required-field + A2 ; \field Erl Variable 1 Name + \begin-extensible + \required-field + \type alpha + \note no spaces allowed in name + +OS:EnergyManagementSystem:OutputVariable, + \memo This object sets up an EnergyPlus output variable from an Erl variable + \min-fields 4 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \retaincase + A3 , \field EMS Variable Name + \required-field + \type alpha + \note must be an acceptable EMS variable + A4 , \field Type of Data in Variable + \required-field + \type choice + \key Averaged + \key Summed + A5 , \field Update Frequency + \required-field + \type choice + \key ZoneTimestep + \key SystemTimestep + A6 , \field EMS Program or Subroutine Name + \type alpha + \note optional for global scope variables, required for local scope variables + A7 ; \field Units + \note optional but will result in dimensionless units for blank + \note EnergyPlus units are standard SI units + \type alpha + +OS:EnergyManagementSystem:MeteredOutputVariable, + \memo This object sets up an EnergyPlus output variable from an Erl variable + \min-fields 7 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \retaincase + A3 , \field EMS Variable Name + \required-field + \type alpha + \note must be an acceptable EMS variable, no spaces + A4 , \field Update Frequency + \required-field + \type choice + \key ZoneTimestep + \key SystemTimestep + A5 , \field EMS Program or Subroutine Name + \type alpha + \note optional for global scope variables, required for local scope variables + A6 , \field Resource Type + \required-field + \note choose the type of fuel, water, electricity, pollution or heat rate that should be metered. + \type choice + \key Electricity + \key NaturalGas + \key Gasoline + \key Diesel + \key Coal + \key FuelOil#1 + \key FuelOil#2 + \key Propane + \key OtherFuel1 + \key OtherFuel2 + \key WaterUse + \key OnSiteWaterProduced + \key MainsWaterSupply + \key RainWaterCollected + \key WellWaterDrawn + \key CondensateWaterCollected + \key EnergyTransfer + \key Steam + \key DistrictCooling + \key DistrictHeating + \key ElectricityProducedOnSite + \key SolarWaterHeating + \key SolarAirHeating + A7 , \field Group Type + \note choose a general classification, building (internal services), HVAC (air systems), or plant (hydronic systems), or system + \type choice + \required-field + \key Building + \key HVAC + \key Plant + \key System + A8 , \field End-Use Category + \note choose how the metered output should be classified for end-use category + \required-field + \type choice + \key Heating + \key Cooling + \key InteriorLights + \key ExteriorLights + \key InteriorEquipment + \key ExteriorEquipment + \key Fans + \key Pumps + \key HeatRejection + \key Humidifier + \key HeatRecovery + \key WaterSystems + \key Refrigeration + \key OnSiteGeneration + \key HeatingCoils + \key CoolingCoils + \key Chillers + \key Boilers + \key Baseboard + \key HeatRecoveryForCooling + \key HeatRecoveryForHeating + A9 , \field End-Use Subcategory + \type alpha + \note enter a user-defined subcategory for this metered output + A10 ; \field Units + \note optional but will result in dimensionless units for blank + \note EnergyPlus units are standard SI units + \type alpha + +OS:EnergyManagementSystem:TrendVariable, + \memo This object sets up an EMS trend variable from an Erl variable + \memo A trend variable logs values across timesteps + \min-fields 3 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note no spaces allowed in name + A3 , \field EMS Variable Name + \required-field + \type alpha + \note must be a global scope EMS variable + N1 ; \field Number of Timesteps to be Logged + \required-field + \type integer + \minimum 1 + +OS:EnergyManagementSystem:InternalVariable, + \memo Declares EMS variable as an internal data variable + \min-fields 3 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note This name becomes a variable for use in Erl programs + \note no spaces allowed in name + A3 , \field Internal Data Index Key Name + \type alpha + A4 ; \field Internal Data Type + \required-field + \type alpha + +OS:EnergyManagementSystem:CurveOrTableIndexVariable, + \memo Declares EMS variable that identifies a curve or table + \min-fields 2 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note This name becomes a variable for use in Erl programs + \note no spaces allowed in name + A3 ; \field Curve or Table Object Name + \type object-list + \object-list AllCurves + \required-field + +OS:EnergyManagementSystem:ConstructionIndexVariable, + \memo Declares EMS variable that identifies a construction + \min-fields 2 + A1, \field Handle + \type handle + \required-field + A2 , \field Name + \required-field + \type alpha + \note This name becomes a variable for use in Erl programs + \note no spaces allowed in name + A3 ; \field Construction Object Name + \type object-list + \object-list ConstructionNames + \required-field + From dca56125cb2051ecf07f84b4503ada84eb50aad0 Mon Sep 17 00:00:00 2001 From: Dan Macumber Date: Tue, 12 Jul 2016 13:00:39 -0600 Subject: [PATCH 002/159] Updates to EMS IDD: Reference OutputVariable and OutputMeter objects Reference actuated component Add one to minimum number of fields for handle field Use reference groups to ensure unique names API changes: We will want to add code in Workspace to enforce no spaces in ERL* Name fields --- openstudiocore/resources/model/OpenStudio.idd | 91 +++++++++++-------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 278425e884b..cc6b3b6d805 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26236,9 +26236,9 @@ OS:Output:Meter, A2, \field Name \note Form is EnergyUseType:..., e.g. Electricity:* for all Electricity meters \note or EndUse:..., e.g. GeneralLights:* for all General Lights - \type external-list \required-field - \external-list autoRDDmeter + \reference OutputMeterNames + \reference OutputVariableMeterNames A3, \field Reporting Frequency \note Timestep refers to the zone Timestep/Number of Timesteps in hour value \note RunPeriod, Environment, and Annual are the same @@ -26277,6 +26277,7 @@ OS:Output:Variable, \type alpha \required-field \reference OutputVariableNames + \reference OutputVariableMeterNames A3, \field Key Value \note use '*' (without quotes) to apply this variable to all keys \type alpha @@ -26314,6 +26315,8 @@ OS:Meter:Custom, \required-field A2, \field Name \required-field + \reference OutputMeterNames + \reference OutputVariableMeterNames A3, \field Fuel Type \type choice \key Electricity @@ -26342,6 +26345,8 @@ OS:Meter:CustomDecrement, \required-field A2, \field Name \required-field + \reference OutputMeterNames + \reference OutputVariableMeterNames A3, \field Fuel Type \type choice \key Electricity @@ -26369,7 +26374,7 @@ OS:EnergyManagementSystem:Sensor, \memo a list of output variables and meters that can be reported are available after a run on \memo the report (.rdd) or meter dictionary file (.mdd) if the Output:VariableDictionary \memo has been requested. - \min-fields 3 + \min-fields 4 A1, \field Handle \type handle \required-field @@ -26377,13 +26382,15 @@ OS:EnergyManagementSystem:Sensor, \required-field \type alpha \note This name becomes a variable for use in Erl programs - \note no spaces allowed in name - A3 , \field Output:Variable or Output:Meter Index Key Name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames + A3 , \field Output Variable or Output Meter Index Key Name \type alpha - A4 ; \field Output:Variable or Output:Meter Name + \note key name listed here will override key name in Output:Variable or Output:Meter + A4 ; \field Output Variable or Output Meter Name \required-field - \type external-list - \external-list autoRDDvariableMeter + \type object-list + \object-list OutputVariableMeterNames OS:EnergyManagementSystem:Actuator, \memo Hardware portion of EMS used to set up actuators in the model @@ -26395,14 +26402,13 @@ OS:EnergyManagementSystem:Actuator, \required-field \type alpha \note This name becomes a variable for use in Erl programs - \note no spaces allowed in name - A3 , \field Actuated Component Unique Name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames + A3 , \field Actuated Component Name \required-field \type alpha - A4 , \field Actuated Component Type - \required-field - \type alpha - A5 ; \field Actuated Component Control Type + \object-list AllObjects + A4 ; \field Actuated Component Control Type \required-field \type alpha @@ -26411,15 +26417,15 @@ OS:EnergyManagementSystem:ProgramCallingManager, \memo Input EMS program. a program needs a name \memo a description of when it should be called \memo and then lines of program code for EMS Runtime language - \min-fields 3 + \min-fields 4 A1, \field Handle \type handle \required-field A2 , \field Name \required-field \type alpha - \reference ProgramNames - \note no spaces allowed in name + \reference ErlProgramCallingManagerNames + \note No spaces allowed in names for ErlProgramCallingManagerNames A3 , \field EnergyPlus Model Calling Point \type choice \key BeginNewEnvironment @@ -26437,7 +26443,7 @@ OS:EnergyManagementSystem:ProgramCallingManager, \key AfterComponentInputReadIn \key UserDefinedComponentModel \key UnitarySystemSizing - A4 ; \field Program Name 1 + A4 ; \field Program Name \begin-extensible \required-field \type object-list @@ -26448,7 +26454,7 @@ OS:EnergyManagementSystem:Program, \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. \memo This input defines an Erl program \memo Each field after the name is a line of EMS Runtime Language - \min-fields 2 + \min-fields 3 A1, \field Handle \type handle \required-field @@ -26456,8 +26462,9 @@ OS:EnergyManagementSystem:Program, \required-field \type alpha \reference ErlProgramNames - \note no spaces allowed in name - A3 ; \field Program Line 1 + \reference ErlProgramSubroutineNames + \note No spaces allowed in names for ErlProgramNames + A3 ; \field Program Line \begin-extensible \type alpha \required-field @@ -26466,28 +26473,30 @@ OS:EnergyManagementSystem:Subroutine, \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. \memo This input defines an Erl program subroutine \memo Each field after the name is a line of EMS Runtime Language - \min-fields 2 + \min-fields 3 A1, \field Handle \type handle \required-field A2 , \field Name \required-field \type alpha - \reference ErlProgramNames - \note no spaces allowed in name - A3 ; \field Program Line 1 + \reference ErlSubroutineNames + \reference ErlProgramSubroutineNames + \note No spaces allowed in names for ErlSubroutineNames + A3 ; \field Program Line \begin-extensible \type alpha + \required-field - OS:EnergyManagementSystem:GlobalVariable, +OS:EnergyManagementSystem:GlobalVariable, \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. \memo Declares Erl variable as having global scope \memo No spaces allowed in names used for Erl variables - \min-fields 1 + \min-fields 2 A1, \field Handle \type handle \required-field - A2 ; \field Erl Variable 1 Name + A2 ; \field Erl Variable Name \begin-extensible \required-field \type alpha @@ -26495,7 +26504,7 @@ OS:EnergyManagementSystem:Subroutine, OS:EnergyManagementSystem:OutputVariable, \memo This object sets up an EnergyPlus output variable from an Erl variable - \min-fields 4 + \min-fields 5 A1, \field Handle \type handle \required-field @@ -26519,6 +26528,7 @@ OS:EnergyManagementSystem:OutputVariable, \key SystemTimestep A6 , \field EMS Program or Subroutine Name \type alpha + \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables A7 ; \field Units \note optional but will result in dimensionless units for blank @@ -26527,7 +26537,7 @@ OS:EnergyManagementSystem:OutputVariable, OS:EnergyManagementSystem:MeteredOutputVariable, \memo This object sets up an EnergyPlus output variable from an Erl variable - \min-fields 7 + \min-fields 8 A1, \field Handle \type handle \required-field @@ -26546,6 +26556,7 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \key SystemTimestep A5 , \field EMS Program or Subroutine Name \type alpha + \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables A6 , \field Resource Type \required-field @@ -26618,14 +26629,15 @@ OS:EnergyManagementSystem:MeteredOutputVariable, OS:EnergyManagementSystem:TrendVariable, \memo This object sets up an EMS trend variable from an Erl variable \memo A trend variable logs values across timesteps - \min-fields 3 + \min-fields 4 A1, \field Handle \type handle \required-field A2 , \field Name \required-field \type alpha - \note no spaces allowed in name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames A3 , \field EMS Variable Name \required-field \type alpha @@ -26637,7 +26649,7 @@ OS:EnergyManagementSystem:TrendVariable, OS:EnergyManagementSystem:InternalVariable, \memo Declares EMS variable as an internal data variable - \min-fields 3 + \min-fields 4 A1, \field Handle \type handle \required-field @@ -26645,7 +26657,8 @@ OS:EnergyManagementSystem:InternalVariable, \required-field \type alpha \note This name becomes a variable for use in Erl programs - \note no spaces allowed in name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames A3 , \field Internal Data Index Key Name \type alpha A4 ; \field Internal Data Type @@ -26654,7 +26667,7 @@ OS:EnergyManagementSystem:InternalVariable, OS:EnergyManagementSystem:CurveOrTableIndexVariable, \memo Declares EMS variable that identifies a curve or table - \min-fields 2 + \min-fields 3 A1, \field Handle \type handle \required-field @@ -26662,7 +26675,8 @@ OS:EnergyManagementSystem:CurveOrTableIndexVariable, \required-field \type alpha \note This name becomes a variable for use in Erl programs - \note no spaces allowed in name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames A3 ; \field Curve or Table Object Name \type object-list \object-list AllCurves @@ -26670,7 +26684,7 @@ OS:EnergyManagementSystem:CurveOrTableIndexVariable, OS:EnergyManagementSystem:ConstructionIndexVariable, \memo Declares EMS variable that identifies a construction - \min-fields 2 + \min-fields 3 A1, \field Handle \type handle \required-field @@ -26678,7 +26692,8 @@ OS:EnergyManagementSystem:ConstructionIndexVariable, \required-field \type alpha \note This name becomes a variable for use in Erl programs - \note no spaces allowed in name + \note No spaces allowed in names for ErlVariableNames + \reference ErlVariableNames A3 ; \field Construction Object Name \type object-list \object-list ConstructionNames From 5ddb3a4bf2a67e86c0656ec4fdcfaeb18540d614 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 12 Jul 2016 22:20:36 -0600 Subject: [PATCH 003/159] add EMS to OSCpre --- openstudiocore/src/model/CMakeLists.txt | 12 ++ .../src/model/ConcreteModelObjects.hpp | 4 + .../model/EnergyManagementSystemActuator.cpp | 129 +++++++++++++++ .../model/EnergyManagementSystemActuator.hpp | 94 +++++++++++ .../EnergyManagementSystemActuator_Impl.hpp | 92 +++++++++++ .../model/EnergyManagementSystemProgram.cpp | 89 +++++++++++ .../model/EnergyManagementSystemProgram.hpp | 90 +++++++++++ ...yManagementSystemProgramCallingManager.cpp | 121 ++++++++++++++ ...yManagementSystemProgramCallingManager.hpp | 98 ++++++++++++ ...gementSystemProgramCallingManager_Impl.hpp | 94 +++++++++++ .../EnergyManagementSystemProgram_Impl.hpp | 88 +++++++++++ .../model/EnergyManagementSystemSensor.cpp | 148 ++++++++++++++++++ .../model/EnergyManagementSystemSensor.hpp | 101 ++++++++++++ .../EnergyManagementSystemSensor_Impl.hpp | 105 +++++++++++++ openstudiocore/src/model/Model.cpp | 8 + openstudiocore/src/model/ModelCore.i | 8 + 16 files changed, 1281 insertions(+) create mode 100644 openstudiocore/src/model/EnergyManagementSystemActuator.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemActuator.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgram.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgram.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSensor.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSensor.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index f2c946590ca..e2e6a9c0b4f 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -452,6 +452,18 @@ set(${target_name}_src ElectricLoadCenterStorageSimple.hpp ElectricLoadCenterStorageSimple_Impl.hpp ElectricLoadCenterStorageSimple.cpp + EnergyManagementSystemActuator.cpp + EnergyManagementSystemActuator.hpp + EnergyManagementSystemActuator_Impl.hpp + EnergyManagementSystemProgram.cpp + EnergyManagementSystemProgram.hpp + EnergyManagementSystemProgram_Impl.hpp + EnergyManagementSystemProgramCallingManager.cpp + EnergyManagementSystemProgramCallingManager.hpp + EnergyManagementSystemProgramCallingManager_Impl.hpp + EnergyManagementSystemSensor.cpp + EnergyManagementSystemSensor.hpp + EnergyManagementSystemSensor_Impl.hpp EvaporativeCoolerDirectResearchSpecial.hpp EvaporativeCoolerDirectResearchSpecial_Impl.hpp EvaporativeCoolerDirectResearchSpecial.cpp diff --git a/openstudiocore/src/model/ConcreteModelObjects.hpp b/openstudiocore/src/model/ConcreteModelObjects.hpp index 759fd598561..4ebf9ffc1f3 100644 --- a/openstudiocore/src/model/ConcreteModelObjects.hpp +++ b/openstudiocore/src/model/ConcreteModelObjects.hpp @@ -155,6 +155,10 @@ #include "ElectricLoadCenterInverterLookUpTable.hpp" #include "ElectricLoadCenterInverterSimple.hpp" #include "ElectricLoadCenterStorageSimple.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemProgramCallingManager.hpp" +#include "EnergyManagementSystemSensor.hpp" #include "EvaporativeCoolerDirectResearchSpecial.hpp" #include "EvaporativeCoolerIndirectResearchSpecial.hpp" #include "EvaporativeFluidCoolerSingleSpeed.hpp" diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp new file mode 100644 index 00000000000..d261c2fe28c --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -0,0 +1,129 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemActuator_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemActuator_Impl::EnergyManagementSystemActuator_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemActuator::iddObjectType()); + } + + EnergyManagementSystemActuator_Impl::EnergyManagementSystemActuator_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemActuator::iddObjectType()); + } + + EnergyManagementSystemActuator_Impl::EnergyManagementSystemActuator_Impl(const EnergyManagementSystemActuator_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemActuator_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemActuator_Impl::iddObjectType() const { + return EnergyManagementSystemActuator::iddObjectType(); + } + + std::string EnergyManagementSystemActuator_Impl::actuatedComponentName() const { + boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const { + boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType,true); + OS_ASSERT(value); + return value.get(); + } + + void EnergyManagementSystemActuator_Impl::setActuatedComponentName(const std::string& actuatedComponentName) { + bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, actuatedComponentName); + OS_ASSERT(result); + } + + void EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { + bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType); + OS_ASSERT(result); + } + +} // detail + +EnergyManagementSystemActuator::EnergyManagementSystemActuator(const Model& model) + : ModelObject(EnergyManagementSystemActuator::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // setActuatedComponentName(); + // setActuatedComponentControlType(); +} + +IddObjectType EnergyManagementSystemActuator::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Actuator); +} + +std::string EnergyManagementSystemActuator::actuatedComponentName() const { + return getImpl()->actuatedComponentName(); +} + +std::string EnergyManagementSystemActuator::actuatedComponentControlType() const { + return getImpl()->actuatedComponentControlType(); +} + +void EnergyManagementSystemActuator::setActuatedComponentName(const std::string& actuatedComponentName) { + getImpl()->setActuatedComponentName(actuatedComponentName); +} + +void EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { + getImpl()->setActuatedComponentControlType(actuatedComponentControlType); +} + +/// @cond +EnergyManagementSystemActuator::EnergyManagementSystemActuator(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp new file mode 100644 index 00000000000..ea2f534c38d --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -0,0 +1,94 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemActuator_Impl; + +} // detail + +/** EnergyManagementSystemActuator is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:Actuator'. */ +class MODEL_API EnergyManagementSystemActuator : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemActuator(const Model& model); + + virtual ~EnergyManagementSystemActuator() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + std::string actuatedComponentName() const; + + std::string actuatedComponentControlType() const; + + //@} + /** @name Setters */ + //@{ + + void setActuatedComponentName(const std::string& actuatedComponentName); + + void setActuatedComponentControlType(const std::string& actuatedComponentControlType); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemActuator_Impl ImplType; + + explicit EnergyManagementSystemActuator(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemActuator_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemActuator"); +}; + +/** \relates EnergyManagementSystemActuator*/ +typedef boost::optional OptionalEnergyManagementSystemActuator; + +/** \relates EnergyManagementSystemActuator*/ +typedef std::vector EnergyManagementSystemActuatorVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp new file mode 100644 index 00000000000..631541797a0 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp @@ -0,0 +1,92 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemActuator_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemActuator.*/ + class MODEL_API EnergyManagementSystemActuator_Impl : public ModelObject_Impl { + Q_OBJECT; + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemActuator_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemActuator_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemActuator_Impl(const EnergyManagementSystemActuator_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemActuator_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + std::string actuatedComponentName() const; + + std::string actuatedComponentControlType() const; + + //@} + /** @name Setters */ + //@{ + + void setActuatedComponentName(const std::string& actuatedComponentName); + + void setActuatedComponentControlType(const std::string& actuatedComponentControlType); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemActuator"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMACTUATOR_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp new file mode 100644 index 00000000000..4faa6e2c3f3 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -0,0 +1,89 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemProgram_Impl::EnergyManagementSystemProgram_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemProgram::iddObjectType()); + } + + EnergyManagementSystemProgram_Impl::EnergyManagementSystemProgram_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemProgram::iddObjectType()); + } + + EnergyManagementSystemProgram_Impl::EnergyManagementSystemProgram_Impl(const EnergyManagementSystemProgram_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemProgram_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemProgram_Impl::iddObjectType() const { + return EnergyManagementSystemProgram::iddObjectType(); + } + +} // detail + +EnergyManagementSystemProgram::EnergyManagementSystemProgram(const Model& model) + : ModelObject(EnergyManagementSystemProgram::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. +} + +IddObjectType EnergyManagementSystemProgram::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Program); +} + +/// @cond +EnergyManagementSystemProgram::EnergyManagementSystemProgram(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp new file mode 100644 index 00000000000..41e976db873 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -0,0 +1,90 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemProgram_Impl; + +} // detail + +/** EnergyManagementSystemProgram is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:Program'. */ +class MODEL_API EnergyManagementSystemProgram : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemProgram(const Model& model); + + virtual ~EnergyManagementSystemProgram() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemProgram_Impl ImplType; + + explicit EnergyManagementSystemProgram(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemProgram_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemProgram"); +}; + +/** \relates EnergyManagementSystemProgram*/ +typedef boost::optional OptionalEnergyManagementSystemProgram; + +/** \relates EnergyManagementSystemProgram*/ +typedef std::vector EnergyManagementSystemProgramVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp new file mode 100644 index 00000000000..09aa46cdfe3 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -0,0 +1,121 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemProgramCallingManager.hpp" +#include "EnergyManagementSystemProgramCallingManager_Impl.hpp" + +#include +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemProgramCallingManager_Impl::EnergyManagementSystemProgramCallingManager_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemProgramCallingManager::iddObjectType()); + } + + EnergyManagementSystemProgramCallingManager_Impl::EnergyManagementSystemProgramCallingManager_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemProgramCallingManager::iddObjectType()); + } + + EnergyManagementSystemProgramCallingManager_Impl::EnergyManagementSystemProgramCallingManager_Impl(const EnergyManagementSystemProgramCallingManager_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemProgramCallingManager_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemProgramCallingManager_Impl::iddObjectType() const { + return EnergyManagementSystemProgramCallingManager::iddObjectType(); + } + + boost::optional EnergyManagementSystemProgramCallingManager_Impl::energyPlusModelCallingPoint() const { + return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint,true); + } + + bool EnergyManagementSystemProgramCallingManager_Impl::setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint) { + bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, energyPlusModelCallingPoint); + return result; + } + + void EnergyManagementSystemProgramCallingManager_Impl::resetEnergyPlusModelCallingPoint() { + bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, ""); + OS_ASSERT(result); + } + +} // detail + +EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(const Model& model) + : ModelObject(EnergyManagementSystemProgramCallingManager::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. +} + +IddObjectType EnergyManagementSystemProgramCallingManager::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); +} + +std::vector EnergyManagementSystemProgramCallingManager::energyPlusModelCallingPointValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); +} + +boost::optional EnergyManagementSystemProgramCallingManager::energyPlusModelCallingPoint() const { + return getImpl()->energyPlusModelCallingPoint(); +} + +bool EnergyManagementSystemProgramCallingManager::setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint) { + return getImpl()->setEnergyPlusModelCallingPoint(energyPlusModelCallingPoint); +} + +void EnergyManagementSystemProgramCallingManager::resetEnergyPlusModelCallingPoint() { + getImpl()->resetEnergyPlusModelCallingPoint(); +} + +/// @cond +EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp new file mode 100644 index 00000000000..e9a80ae5f9c --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -0,0 +1,98 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemProgramCallingManager_Impl; + +} // detail + +/** EnergyManagementSystemProgramCallingManager is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:ProgramCallingManager'. */ +class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemProgramCallingManager(const Model& model); + + virtual ~EnergyManagementSystemProgramCallingManager() {} + + //@} + + static IddObjectType iddObjectType(); + + static std::vector energyPlusModelCallingPointValues(); + + /** @name Getters */ + //@{ + + boost::optional energyPlusModelCallingPoint() const; + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); + + void resetEnergyPlusModelCallingPoint(); + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemProgramCallingManager_Impl ImplType; + + explicit EnergyManagementSystemProgramCallingManager(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemProgramCallingManager_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemProgramCallingManager"); +}; + +/** \relates EnergyManagementSystemProgramCallingManager*/ +typedef boost::optional OptionalEnergyManagementSystemProgramCallingManager; + +/** \relates EnergyManagementSystemProgramCallingManager*/ +typedef std::vector EnergyManagementSystemProgramCallingManagerVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp new file mode 100644 index 00000000000..e00abe54f0b --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -0,0 +1,94 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemProgramCallingManager_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemProgramCallingManager.*/ + class MODEL_API EnergyManagementSystemProgramCallingManager_Impl : public ModelObject_Impl { + Q_OBJECT; + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemProgramCallingManager_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemProgramCallingManager_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemProgramCallingManager_Impl(const EnergyManagementSystemProgramCallingManager_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemProgramCallingManager_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + boost::optional energyPlusModelCallingPoint() const; + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); + + void resetEnergyPlusModelCallingPoint(); + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemProgramCallingManager"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMPROGRAMCALLINGMANAGER_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp new file mode 100644 index 00000000000..51137fa7445 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -0,0 +1,88 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemProgram_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemProgram.*/ + class MODEL_API EnergyManagementSystemProgram_Impl : public ModelObject_Impl { + Q_OBJECT; + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemProgram_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemProgram_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemProgram_Impl(const EnergyManagementSystemProgram_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemProgram_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemProgram"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMPROGRAM_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp new file mode 100644 index 00000000000..7ae35478acc --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -0,0 +1,148 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" + +// TODO: Check the following class names against object getters and setters. +#include "OutputVariableMeter.hpp" +#include "OutputVariableMeter_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemSensor_Impl::EnergyManagementSystemSensor_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemSensor::iddObjectType()); + } + + EnergyManagementSystemSensor_Impl::EnergyManagementSystemSensor_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemSensor::iddObjectType()); + } + + EnergyManagementSystemSensor_Impl::EnergyManagementSystemSensor_Impl(const EnergyManagementSystemSensor_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemSensor_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemSensor_Impl::iddObjectType() const { + return EnergyManagementSystemSensor::iddObjectType(); + } + + boost::optional EnergyManagementSystemSensor_Impl::outputVariableorOutputMeterIndexKeyName() const { + return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName,true); + } + + OutputVariableMeter EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { + boost::optional value = optionalOutputVariableorOutputMeter(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Output Variableor Output Meter attached."); + } + return value.get(); + } + + void EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName) { + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, outputVariableorOutputMeterIndexKeyName); + OS_ASSERT(result); + } + + void EnergyManagementSystemSensor_Impl::resetOutputVariableorOutputMeterIndexKeyName() { + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, ""); + OS_ASSERT(result); + } + + bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter) { + bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariableMeter.handle()); + return result; + } + + boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + } + +} // detail + +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model) + : ModelObject(EnergyManagementSystemSensor::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName + bool ok = true; + // ok = setOutputVariableorOutputMeter(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemSensor::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Sensor); +} + +boost::optional EnergyManagementSystemSensor::outputVariableorOutputMeterIndexKeyName() const { + return getImpl()->outputVariableorOutputMeterIndexKeyName(); +} + +OutputVariableMeter EnergyManagementSystemSensor::outputVariableorOutputMeter() const { + return getImpl()->outputVariableorOutputMeter(); +} + +void EnergyManagementSystemSensor::setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName) { + getImpl()->setOutputVariableorOutputMeterIndexKeyName(outputVariableorOutputMeterIndexKeyName); +} + +void EnergyManagementSystemSensor::resetOutputVariableorOutputMeterIndexKeyName() { + getImpl()->resetOutputVariableorOutputMeterIndexKeyName(); +} + +bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter) { + return getImpl()->setOutputVariableorOutputMeter(outputVariableMeter); +} + +/// @cond +EnergyManagementSystemSensor::EnergyManagementSystemSensor(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp new file mode 100644 index 00000000000..d806c0f75bc --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -0,0 +1,101 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class OutputVariableMeter; + +namespace detail { + + class EnergyManagementSystemSensor_Impl; + +} // detail + +/** EnergyManagementSystemSensor is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:Sensor'. */ +class MODEL_API EnergyManagementSystemSensor : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemSensor(const Model& model); + + virtual ~EnergyManagementSystemSensor() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + boost::optional outputVariableorOutputMeterIndexKeyName() const; + + // TODO: Check return type. From object lists, some candidates are: OutputVariableMeter. + OutputVariableMeter outputVariableorOutputMeter() const; + + //@} + /** @name Setters */ + //@{ + + void setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName); + + void resetOutputVariableorOutputMeterIndexKeyName(); + + // TODO: Check argument type. From object lists, some candidates are: OutputVariableMeter. + bool setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemSensor_Impl ImplType; + + explicit EnergyManagementSystemSensor(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemSensor_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSensor"); +}; + +/** \relates EnergyManagementSystemSensor*/ +typedef boost::optional OptionalEnergyManagementSystemSensor; + +/** \relates EnergyManagementSystemSensor*/ +typedef std::vector EnergyManagementSystemSensorVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp new file mode 100644 index 00000000000..03f0db28d1b --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -0,0 +1,105 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class OutputVariableMeter; + +namespace detail { + + /** EnergyManagementSystemSensor_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemSensor.*/ + class MODEL_API EnergyManagementSystemSensor_Impl : public ModelObject_Impl { + Q_OBJECT; + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemSensor_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemSensor_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemSensor_Impl(const EnergyManagementSystemSensor_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemSensor_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + boost::optional outputVariableorOutputMeterIndexKeyName() const; + + // TODO: Check return type. From object lists, some candidates are: OutputVariableMeter. + OutputVariableMeter outputVariableorOutputMeter() const; + + //@} + /** @name Setters */ + //@{ + + void setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName); + + void resetOutputVariableorOutputMeterIndexKeyName(); + + // TODO: Check argument type. From object lists, some candidates are: OutputVariableMeter. + bool setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSensor"); + + // TODO: Check the return types of these methods. + // Optional getters for use by methods like children() so can remove() if the constructor fails. + // There are other ways for the public versions of these getters to fail--perhaps all required + // objects should be returned as boost::optionals + boost::optional optionalOutputVariableorOutputMeter() const; + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMSENSOR_IMPL_HPP + diff --git a/openstudiocore/src/model/Model.cpp b/openstudiocore/src/model/Model.cpp index ea0b4f3c833..58a48f488da 100644 --- a/openstudiocore/src/model/Model.cpp +++ b/openstudiocore/src/model/Model.cpp @@ -323,6 +323,10 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_CONSTRUCTOR(ElectricLoadCenterInverterLookUpTable); REGISTER_CONSTRUCTOR(ElectricLoadCenterInverterSimple); REGISTER_CONSTRUCTOR(ElectricLoadCenterStorageSimple); + REGISTER_CONSTRUCTOR(EnergyManagementSystemActuator); + REGISTER_CONSTRUCTOR(EnergyManagementSystemProgram); + REGISTER_CONSTRUCTOR(EnergyManagementSystemProgramCallingManager); + REGISTER_CONSTRUCTOR(EnergyManagementSystemSensor); REGISTER_CONSTRUCTOR(EvaporativeCoolerDirectResearchSpecial); REGISTER_CONSTRUCTOR(EvaporativeCoolerIndirectResearchSpecial); REGISTER_CONSTRUCTOR(EvaporativeFluidCoolerSingleSpeed); @@ -733,6 +737,10 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_COPYCONSTRUCTORS(ElectricLoadCenterInverterLookUpTable); REGISTER_COPYCONSTRUCTORS(ElectricLoadCenterInverterSimple); REGISTER_COPYCONSTRUCTORS(ElectricLoadCenterStorageSimple); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemActuator); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemProgram); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemProgramCallingManager); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemSensor); REGISTER_COPYCONSTRUCTORS(EvaporativeCoolerDirectResearchSpecial); REGISTER_COPYCONSTRUCTORS(EvaporativeCoolerIndirectResearchSpecial); REGISTER_COPYCONSTRUCTORS(EvaporativeFluidCoolerSingleSpeed); diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index f26e5c6a44a..4afd805b643 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -170,6 +170,10 @@ MODELOBJECT_TEMPLATES(ScheduleRuleset); MODELOBJECT_TEMPLATES(OutputVariable); MODELOBJECT_TEMPLATES(GenericModelObject); MODELOBJECT_TEMPLATES(ModelObjectList); +MODELOBJECT_TEMPLATES(EnergyManagementSystemSensor); +MODELOBJECT_TEMPLATES(EnergyManagementSystemActuator); +MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); +MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); SWIG_MODELOBJECT(ModelObject, 0); SWIG_MODELEXTENSIBLEGROUP(ModelExtensibleGroup); @@ -196,5 +200,9 @@ SWIG_MODELOBJECT(ScheduleRuleset, 1); SWIG_MODELOBJECT(OutputVariable, 1); SWIG_MODELOBJECT(GenericModelObject, 0); SWIG_MODELOBJECT(ModelObjectList, 1); +SWIG_MODELOBJECT(EnergyManagementSystemSensor, 1); +SWIG_MODELOBJECT(EnergyManagementSystemActuator, 1); +SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); +SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); #endif //MODEL_CORE_I From b1025e0ec574ee1bdc1cf88af4c3134748f68078 Mon Sep 17 00:00:00 2001 From: Dan Macumber Date: Wed, 13 Jul 2016 09:32:31 -0600 Subject: [PATCH 004/159] Update to script to not include Q_Object --- developer/ruby/GenerateClass.rb | 2 +- developer/ruby/MakeModelObjects.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/developer/ruby/GenerateClass.rb b/developer/ruby/GenerateClass.rb index b7137046b85..fc14ef7ee4d 100644 --- a/developer/ruby/GenerateClass.rb +++ b/developer/ruby/GenerateClass.rb @@ -24,7 +24,7 @@ # # == Usage # -# ruby GenerateClass.rb -s "model" -c "Construction" -b "ConstructionBase" -o "." -p -q -i "OS:Construction" +# ruby GenerateClass.rb -s "model" -c "Construction" -b "ConstructionBase" -o "." -p --no-qobject -i "OS:Construction" # ###################################################################### diff --git a/developer/ruby/MakeModelObjects.rb b/developer/ruby/MakeModelObjects.rb index ab3296f178f..5cef4f1b449 100644 --- a/developer/ruby/MakeModelObjects.rb +++ b/developer/ruby/MakeModelObjects.rb @@ -96,7 +96,7 @@ failed_objects = [] objects.each do |object| - command = "ruby -I #{includePath} GenerateClass.rb -s 'model' -c '#{object[1]}' -b '#{object[2]}' -o #{outDir} -p -q -i '#{object[0].gsub(':','_')}' > #{outDir}/logs/#{object[0].gsub(':','_')}.log 2>&1 " + command = "ruby -I #{includePath} GenerateClass.rb -s 'model' -c '#{object[1]}' -b '#{object[2]}' -o #{outDir} -p --no-qobject -i '#{object[0].gsub(':','_')}' > #{outDir}/logs/#{object[0].gsub(':','_')}.log 2>&1 " puts command result = system(command) failed_objects << object if not result From e692dc58bc43be9869ce88b7177ee4b9cb0b9d17 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 13 Jul 2016 14:34:51 -0600 Subject: [PATCH 005/159] changing outputVariableMeter to outputVariable and outputMeter in some cases --- openstudiocore/src/model/ConcreteModelObjects.hpp | 4 ++++ .../src/model/EnergyManagementSystemActuator.hpp | 6 +++--- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 1 - .../src/model/EnergyManagementSystemProgram_Impl.hpp | 1 - openstudiocore/src/model/EnergyManagementSystemSensor.cpp | 6 ++++-- openstudiocore/src/model/EnergyManagementSystemSensor.hpp | 7 ++++--- .../src/model/EnergyManagementSystemSensor_Impl.hpp | 1 - 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/openstudiocore/src/model/ConcreteModelObjects.hpp b/openstudiocore/src/model/ConcreteModelObjects.hpp index 4ebf9ffc1f3..89056f79c19 100644 --- a/openstudiocore/src/model/ConcreteModelObjects.hpp +++ b/openstudiocore/src/model/ConcreteModelObjects.hpp @@ -537,6 +537,10 @@ #include "ElectricLoadCenterInverterLookUpTable_Impl.hpp" #include "ElectricLoadCenterInverterSimple_Impl.hpp" #include "ElectricLoadCenterStorageSimple_Impl.hpp" +#include "EnergyManagementSystemActuator_Impl.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" +#include "EnergyManagementSystemProgramCallingManager_Impl.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" #include "EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" #include "EvaporativeFluidCoolerSingleSpeed_Impl.hpp" diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index ea2f534c38d..ec73e83cbe3 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -49,7 +49,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Getters */ //@{ - std::string actuatedComponentName() const; + ModelObject actuatedComponentName() const; std::string actuatedComponentControlType() const; @@ -57,9 +57,9 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Setters */ //@{ - void setActuatedComponentName(const std::string& actuatedComponentName); + bool setActuatedComponentName(const ModelObject&); - void setActuatedComponentControlType(const std::string& actuatedComponentControlType); + bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index e00abe54f0b..a06189962dc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -30,7 +30,6 @@ namespace detail { /** EnergyManagementSystemProgramCallingManager_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemProgramCallingManager.*/ class MODEL_API EnergyManagementSystemProgramCallingManager_Impl : public ModelObject_Impl { - Q_OBJECT; public: /** @name Constructors and Destructors */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index 51137fa7445..63189104b33 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -30,7 +30,6 @@ namespace detail { /** EnergyManagementSystemProgram_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemProgram.*/ class MODEL_API EnergyManagementSystemProgram_Impl : public ModelObject_Impl { - Q_OBJECT; public: /** @name Constructors and Destructors */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 7ae35478acc..b8adff7762a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -21,8 +21,10 @@ #include "EnergyManagementSystemSensor_Impl.hpp" // TODO: Check the following class names against object getters and setters. -#include "OutputVariableMeter.hpp" -#include "OutputVariableMeter_Impl.hpp" +#include "OutputVariable.hpp" +#include "OutputVariable_Impl.hpp" +#include "OutputMeter.hpp" +#include "OutputMeter_Impl.hpp" #include #include diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index d806c0f75bc..a228506ff9c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -55,7 +55,8 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { boost::optional outputVariableorOutputMeterIndexKeyName() const; // TODO: Check return type. From object lists, some candidates are: OutputVariableMeter. - OutputVariableMeter outputVariableorOutputMeter() const; + boost::optional outputVariable() const; + boost::optional outputMeter() const; //@} /** @name Setters */ @@ -66,8 +67,8 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { void resetOutputVariableorOutputMeterIndexKeyName(); // TODO: Check argument type. From object lists, some candidates are: OutputVariableMeter. - bool setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter); - + bool setOutputVariable(const OutputVariable& outputVariable); + bool setOutputMeter(const OutputMeter& outputMeter); //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 03f0db28d1b..38b8c7bfb4d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -33,7 +33,6 @@ namespace detail { /** EnergyManagementSystemSensor_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemSensor.*/ class MODEL_API EnergyManagementSystemSensor_Impl : public ModelObject_Impl { - Q_OBJECT; public: /** @name Constructors and Destructors */ //@{ From 480de2a4222605b666ad0263f37de6c3a4a3c9d2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 13 Jul 2016 14:37:33 -0600 Subject: [PATCH 006/159] add EMS objects to MakeModelObjects.rb --- developer/ruby/MakeModelObjects.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/developer/ruby/MakeModelObjects.rb b/developer/ruby/MakeModelObjects.rb index 5cef4f1b449..5836f95fde5 100644 --- a/developer/ruby/MakeModelObjects.rb +++ b/developer/ruby/MakeModelObjects.rb @@ -21,7 +21,7 @@ # objects << ["OS:Schedule:Rule", "ScheduleRule", "ParentObject"] # objects << ["OS:ConvergenceLimits", "ConvergenceLimits", "ModelObject"] # objects << ["OS:HeatBalanceAlgorithm", "HeatBalanceAlgorithm", "ModelObject"] -objects << ["OS:RunPeriod", "RunPeriod", "ParentObject"] +# objects << ["OS:RunPeriod", "RunPeriod", "ParentObject"] # objects << ["OS:RunPeriodControl:DaylightSavingTime", "DaylightSavingTime", "ModelObject"] # objects << ["OS:RunPeriodControl:SpecialDays", "RunPeriodControlSpecialDays", "ModelObject"] # objects << ["OS:ShadowCalculation", "ShadowCalculation", "ModelObject"] @@ -52,11 +52,11 @@ # objects << ["OS:GasEquipment:Definition", "GasEquipmentDefinition", "SpaceLoadDefinition"] # objects << ["OS:HotWaterEquipment:Definition", "HotWaterEquipmentDefinition", "SpaceLoadDefinition"] # objects << ["OS:InternalMass:Definition", "InternalMassDefinition", "SpaceLoadDefinition"] -objects << ["OS:Lights:Definition", "LightsDefinition", "SpaceLoadDefinition"] +# objects << ["OS:Lights:Definition", "LightsDefinition", "SpaceLoadDefinition"] # objects << ["OS:Luminaire:Definition", "LuminaireDefinition", "SpaceLoadDefinition"] # objects << ["OS:People:Definition", "PeopleDefinition", "SpaceLoadDefinition"] # objects << ["OS:Rendering:Color", "RenderingColor", "ResourceObject"] -objects << ["OS:SpaceType", "SpaceType", "ResourceObject"] +# objects << ["OS:SpaceType", "SpaceType", "ResourceObject"] # objects << ["OS:Building", "Building", "ParentObject"] # objects << ["OS:Daylighting:Control", "DaylightingControl", "SpaceItem"] @@ -70,21 +70,24 @@ # objects << ["OS:InteriorPartitionSurface", "InteriorPartitionSurface", "PlanarSurface"] # objects << ["OS:InternalMass", "InternalMass", "SpaceLoadInstance"] # objects << ["OS:LightingSimulationZone", "LightingSimulationZone", "ModelObject"] -objects << ["OS:Lights", "Lights", "SpaceLoadInstance"] +# objects << ["OS:Lights", "Lights", "SpaceLoadInstance"] # objects << ["OS:Luminaire", "Luminaire", "SpaceLoadInstance"] # objects << ["OS:People", "People", "SpaceLoadInstance"] # objects << ["OS:ShadingSurfaceGroup", "ShadingSurfaceGroup", "PlanarSurfaceGroup"] # objects << ["OS:ShadingSurface", "ShadingSurface", "PlanarSurface"] -objects << ["OS:Space", "Space", "PlanarSurfaceGroup"] -objects << ["OS:Surface", "Surface", "PlanarSurface"] -objects << ["OS:SubSurface", "SubSurface", "PlanarSurface"] +# objects << ["OS:Space", "Space", "PlanarSurfaceGroup"] +# objects << ["OS:Surface", "Surface", "PlanarSurface"] +# objects << ["OS:SubSurface", "SubSurface", "PlanarSurface"] # objects << ["OS:SpaceInfiltration:DesignFlowRate", "SpaceInfiltrationDesignFlowRate", "SpaceLoad"] #objects << ["OS:SpaceVentilation:DesignFlowRate", "SpaceVentilationDesignFlowRate", "SpaceLoad"] # objects << ["OS:LightingDesignDay", "LightingDesignDay", "ModelObject"] # objects << ["OS:LightingSimulationControl", "LightingSimulationControl", "ModelObject"] -objects << ["OS:ThermalZone", "ThermalZone", "HVACComponent"] +objects << ["OS:EnergyManagementSystem:Sensor", "EnergyManagementSystemSensor", "ModelObject"] +objects << ["OS:EnergyManagementSystem:Actuator", "EnergyManagementSystemActuator", "ModelObject"] +objects << ["OS:EnergyManagementSystem:ProgramCallingManager", "EnergyManagementSystemProgramCallingManager", "ModelObject"] +objects << ["OS:EnergyManagementSystem:Program", "EnergyManagementSystemProgram", "ModelObject"] includePath = nil if /mswin/.match(RUBY_PLATFORM) || /mingw/.match(RUBY_PLATFORM) From a2bd7aaec1378f1f1d2e84370ecd0a68c929d724 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 13 Jul 2016 17:34:56 -0600 Subject: [PATCH 007/159] debugging sensor --- openstudiocore/src/model/EnergyManagementSystemActuator.cpp | 6 +++--- openstudiocore/src/model/EnergyManagementSystemActuator.hpp | 2 +- openstudiocore/src/model/EnergyManagementSystemSensor.hpp | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index d261c2fe28c..45ec3214b60 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -88,8 +88,8 @@ namespace detail { } // detail -EnergyManagementSystemActuator::EnergyManagementSystemActuator(const Model& model) - : ModelObject(EnergyManagementSystemActuator::iddObjectType(),model) +EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject) + : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject) { OS_ASSERT(getImpl()); @@ -102,7 +102,7 @@ IddObjectType EnergyManagementSystemActuator::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Actuator); } -std::string EnergyManagementSystemActuator::actuatedComponentName() const { +ModelObject EnergyManagementSystemActuator::actuatedComponentName() const { return getImpl()->actuatedComponentName(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index ec73e83cbe3..742baf0950d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -38,7 +38,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemActuator(const Model& model); + explicit EnergyManagementSystemActuator(const ModelObject& modelObject); virtual ~EnergyManagementSystemActuator() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index a228506ff9c..f8cd8af9b7d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -27,7 +27,8 @@ namespace openstudio { namespace model { // TODO: Check the following class names against object getters and setters. -class OutputVariableMeter; +class OutputVariable; +class OutputMeter; namespace detail { From 7ff951e6d0ab93c0bf11ea2ca8fe783e4cb96265 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 13 Jul 2016 18:57:10 -0600 Subject: [PATCH 008/159] separating outputvariablemeter into outputvariable and outputmeter --- .../model/EnergyManagementSystemSensor.cpp | 45 ++++++++++++++----- .../model/EnergyManagementSystemSensor.hpp | 3 -- .../EnergyManagementSystemSensor_Impl.hpp | 12 ++--- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index b8adff7762a..59c2ae04a4e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -74,10 +74,18 @@ namespace detail { return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName,true); } - OutputVariableMeter EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { - boost::optional value = optionalOutputVariableorOutputMeter(); + OutputVariable EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { + boost::optional value = optionalOutputVariableorOutputMeter(); if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Output Variableor Output Meter attached."); + LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); + } + return value.get(); + } + + OutputMeter EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { + boost::optional value = optionalOutputVariableorOutputMeter(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); } return value.get(); } @@ -92,13 +100,22 @@ namespace detail { OS_ASSERT(result); } - bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter) { - bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariableMeter.handle()); + bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputVariable& outputVariable) { + bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); + return result; + } + + bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputMeter& outputMeter) { + bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); return result; } - boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { - return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + } + + boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); } } // detail @@ -123,7 +140,11 @@ boost::optional EnergyManagementSystemSensor::outputVariableorOutpu return getImpl()->outputVariableorOutputMeterIndexKeyName(); } -OutputVariableMeter EnergyManagementSystemSensor::outputVariableorOutputMeter() const { +OutputVariable EnergyManagementSystemSensor::outputVariableorOutputMeter() const { + return getImpl()->outputVariableorOutputMeter(); +} + +OutputMeter EnergyManagementSystemSensor::outputVariableorOutputMeter() const { return getImpl()->outputVariableorOutputMeter(); } @@ -135,8 +156,12 @@ void EnergyManagementSystemSensor::resetOutputVariableorOutputMeterIndexKeyName( getImpl()->resetOutputVariableorOutputMeterIndexKeyName(); } -bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter) { - return getImpl()->setOutputVariableorOutputMeter(outputVariableMeter); +bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputVariable& outputVariable) { + return getImpl()->setOutputVariableorOutputMeter(outputVariable); +} + +bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputMeter& outputMeter) { + return getImpl()->setOutputVariableorOutputMeter(outputMeter); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index f8cd8af9b7d..a488fd22289 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -26,7 +26,6 @@ namespace openstudio { namespace model { -// TODO: Check the following class names against object getters and setters. class OutputVariable; class OutputMeter; @@ -55,7 +54,6 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { boost::optional outputVariableorOutputMeterIndexKeyName() const; - // TODO: Check return type. From object lists, some candidates are: OutputVariableMeter. boost::optional outputVariable() const; boost::optional outputMeter() const; @@ -67,7 +65,6 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { void resetOutputVariableorOutputMeterIndexKeyName(); - // TODO: Check argument type. From object lists, some candidates are: OutputVariableMeter. bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 38b8c7bfb4d..3843fa87b2d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -65,8 +65,8 @@ namespace detail { boost::optional outputVariableorOutputMeterIndexKeyName() const; - // TODO: Check return type. From object lists, some candidates are: OutputVariableMeter. - OutputVariableMeter outputVariableorOutputMeter() const; + OutputVariable outputVariableorOutputMeter() const; + OutputMeter outputVariableorOutputMeter() const; //@} /** @name Setters */ @@ -76,8 +76,8 @@ namespace detail { void resetOutputVariableorOutputMeterIndexKeyName(); - // TODO: Check argument type. From object lists, some candidates are: OutputVariableMeter. - bool setOutputVariableorOutputMeter(const OutputVariableMeter& outputVariableMeter); + bool setOutputVariableorOutputMeter(const OutputVariable& outputVariable); + bool setOutputVariableorOutputMeter(const OutputMeter& outputMeter); //@} /** @name Other */ @@ -88,11 +88,11 @@ namespace detail { private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSensor"); - // TODO: Check the return types of these methods. // Optional getters for use by methods like children() so can remove() if the constructor fails. // There are other ways for the public versions of these getters to fail--perhaps all required // objects should be returned as boost::optionals - boost::optional optionalOutputVariableorOutputMeter() const; + boost::optional optionalOutputVariableorOutputMeter() const; + boost::optional optionalOutputVariableorOutputMeter() const; }; } // detail From 2cc911eed78ad6620590ecaa2e0ac9c11da8138f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 14 Jul 2016 13:08:35 -0600 Subject: [PATCH 009/159] aligning method declarations --- .../model/EnergyManagementSystemActuator.cpp | 28 +++++++++------- .../model/EnergyManagementSystemActuator.hpp | 2 +- .../EnergyManagementSystemActuator_Impl.hpp | 6 ++-- .../model/EnergyManagementSystemSensor.cpp | 32 +++++++++---------- .../EnergyManagementSystemSensor_Impl.hpp | 12 +++---- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 45ec3214b60..bb5e83699d0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -20,6 +20,9 @@ #include "EnergyManagementSystemActuator.hpp" #include "EnergyManagementSystemActuator_Impl.hpp" +#include "Model.hpp" +#include "Model_Impl.hpp" + #include #include @@ -64,10 +67,12 @@ namespace detail { return EnergyManagementSystemActuator::iddObjectType(); } - std::string EnergyManagementSystemActuator_Impl::actuatedComponentName() const { - boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName,true); - OS_ASSERT(value); - return value.get(); + ModelObject EnergyManagementSystemActuator_Impl::actuatedComponentName() const { + boost::optional result; + result = this->actuatedComponentName(); + OS_ASSERT(result); + return result.get(); + //return OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName(); } std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const { @@ -76,12 +81,11 @@ namespace detail { return value.get(); } - void EnergyManagementSystemActuator_Impl::setActuatedComponentName(const std::string& actuatedComponentName) { - bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, actuatedComponentName); - OS_ASSERT(result); + bool EnergyManagementSystemActuator_Impl::setActuatedComponentName(const ModelObject& modelObject) { + return setPointer(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, modelObject.handle()); } - void EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { + bool EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType); OS_ASSERT(result); } @@ -89,7 +93,7 @@ namespace detail { } // detail EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject) - : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject) + : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { OS_ASSERT(getImpl()); @@ -110,11 +114,11 @@ std::string EnergyManagementSystemActuator::actuatedComponentControlType() const return getImpl()->actuatedComponentControlType(); } -void EnergyManagementSystemActuator::setActuatedComponentName(const std::string& actuatedComponentName) { - getImpl()->setActuatedComponentName(actuatedComponentName); +bool EnergyManagementSystemActuator::setActuatedComponentName(const ModelObject& modelObject) { + getImpl()->setActuatedComponentName(modelObject); } -void EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { +bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { getImpl()->setActuatedComponentControlType(actuatedComponentControlType); } diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index 742baf0950d..b963fe409de 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -57,7 +57,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Setters */ //@{ - bool setActuatedComponentName(const ModelObject&); + bool setActuatedComponentName(const ModelObject& modelObject); bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp index 631541797a0..e5026e277c9 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp @@ -61,7 +61,7 @@ namespace detail { /** @name Getters */ //@{ - std::string actuatedComponentName() const; + ModelObject actuatedComponentName() const; std::string actuatedComponentControlType() const; @@ -69,9 +69,9 @@ namespace detail { /** @name Setters */ //@{ - void setActuatedComponentName(const std::string& actuatedComponentName); + bool setActuatedComponentName(const ModelObject& modelObject); - void setActuatedComponentControlType(const std::string& actuatedComponentControlType); + bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 59c2ae04a4e..3d5b5b8e73a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -74,16 +74,16 @@ namespace detail { return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName,true); } - OutputVariable EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { - boost::optional value = optionalOutputVariableorOutputMeter(); + OutputVariable EnergyManagementSystemSensor_Impl::outputVariable() const { + boost::optional value = optionalOutputVariable(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); } return value.get(); } - OutputMeter EnergyManagementSystemSensor_Impl::outputVariableorOutputMeter() const { - boost::optional value = optionalOutputVariableorOutputMeter(); + OutputMeter EnergyManagementSystemSensor_Impl::outputMeter() const { + boost::optional value = optionalOutputMeter(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); } @@ -100,21 +100,21 @@ namespace detail { OS_ASSERT(result); } - bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputVariable& outputVariable) { + bool EnergyManagementSystemSensor_Impl::setOutputVariable(const OutputVariable& outputVariable) { bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); return result; } - bool EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeter(const OutputMeter& outputMeter) { + bool EnergyManagementSystemSensor_Impl::setOutputMeter(const OutputMeter& outputMeter) { bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); return result; } - boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { + boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariable() const { return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); } - boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariableorOutputMeter() const { + boost::optional EnergyManagementSystemSensor_Impl::optionalOutputMeter() const { return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); } @@ -140,12 +140,12 @@ boost::optional EnergyManagementSystemSensor::outputVariableorOutpu return getImpl()->outputVariableorOutputMeterIndexKeyName(); } -OutputVariable EnergyManagementSystemSensor::outputVariableorOutputMeter() const { - return getImpl()->outputVariableorOutputMeter(); +boost::optional EnergyManagementSystemSensor::outputVariable() const { + return getImpl()->outputVariable(); } -OutputMeter EnergyManagementSystemSensor::outputVariableorOutputMeter() const { - return getImpl()->outputVariableorOutputMeter(); +boost::optional EnergyManagementSystemSensor::outputMeter() const { + return getImpl()->outputMeter(); } void EnergyManagementSystemSensor::setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName) { @@ -156,12 +156,12 @@ void EnergyManagementSystemSensor::resetOutputVariableorOutputMeterIndexKeyName( getImpl()->resetOutputVariableorOutputMeterIndexKeyName(); } -bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputVariable& outputVariable) { - return getImpl()->setOutputVariableorOutputMeter(outputVariable); +bool EnergyManagementSystemSensor::setOutputVariable(const OutputVariable& outputVariable) { + return getImpl()->setOutputVariable(outputVariable); } -bool EnergyManagementSystemSensor::setOutputVariableorOutputMeter(const OutputMeter& outputMeter) { - return getImpl()->setOutputVariableorOutputMeter(outputMeter); +bool EnergyManagementSystemSensor::setOutputMeter(const OutputMeter& outputMeter) { + return getImpl()->setOutputMeter(outputMeter); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 3843fa87b2d..d407365ffa1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -65,8 +65,8 @@ namespace detail { boost::optional outputVariableorOutputMeterIndexKeyName() const; - OutputVariable outputVariableorOutputMeter() const; - OutputMeter outputVariableorOutputMeter() const; + OutputVariable outputVariable() const; + OutputMeter outputMeter() const; //@} /** @name Setters */ @@ -76,8 +76,8 @@ namespace detail { void resetOutputVariableorOutputMeterIndexKeyName(); - bool setOutputVariableorOutputMeter(const OutputVariable& outputVariable); - bool setOutputVariableorOutputMeter(const OutputMeter& outputMeter); + bool setOutputVariable(const OutputVariable& outputVariable); + bool setOutputMeter(const OutputMeter& outputMeter); //@} /** @name Other */ @@ -91,8 +91,8 @@ namespace detail { // Optional getters for use by methods like children() so can remove() if the constructor fails. // There are other ways for the public versions of these getters to fail--perhaps all required // objects should be returned as boost::optionals - boost::optional optionalOutputVariableorOutputMeter() const; - boost::optional optionalOutputVariableorOutputMeter() const; + boost::optional optionalOutputVariable() const; + boost::optional optionalOutputMeter() const; }; } // detail From 63735820356d7b9d71b7714876ff8e62e340e5b4 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 14 Jul 2016 13:56:05 -0600 Subject: [PATCH 010/159] adding return for redefined functions --- .../src/model/EnergyManagementSystemActuator.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index bb5e83699d0..7f4a9b0d4ba 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -68,10 +68,12 @@ namespace detail { } ModelObject EnergyManagementSystemActuator_Impl::actuatedComponentName() const { - boost::optional result; - result = this->actuatedComponentName(); - OS_ASSERT(result); - return result.get(); + + return this->actuatedComponentName(); + //boost::optional result; + //result = this->actuatedComponentName(); + //OS_ASSERT(result); + //return result.get(); //return OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName(); } @@ -88,6 +90,7 @@ namespace detail { bool EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType); OS_ASSERT(result); + return result; } } // detail @@ -115,11 +118,11 @@ std::string EnergyManagementSystemActuator::actuatedComponentControlType() const } bool EnergyManagementSystemActuator::setActuatedComponentName(const ModelObject& modelObject) { - getImpl()->setActuatedComponentName(modelObject); + return getImpl()->setActuatedComponentName(modelObject); } bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { - getImpl()->setActuatedComponentControlType(actuatedComponentControlType); + return getImpl()->setActuatedComponentControlType(actuatedComponentControlType); } /// @cond From 8786cf43e0ca1177daf313e807afdf4fa48c7604 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 14 Jul 2016 14:16:49 -0600 Subject: [PATCH 011/159] update --- openstudiocore/src/model/EnergyManagementSystemActuator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 7f4a9b0d4ba..6b2715d9d45 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -69,7 +69,7 @@ namespace detail { ModelObject EnergyManagementSystemActuator_Impl::actuatedComponentName() const { - return this->actuatedComponentName(); + return this->getTarget(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName)->cast(); //boost::optional result; //result = this->actuatedComponentName(); //OS_ASSERT(result); From 71c669c9dfe52cd36f940a247ab786ec9e787c94 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 14 Jul 2016 16:24:54 -0600 Subject: [PATCH 012/159] convert actuatedComponentName to actuatedComponent --- .../src/model/EnergyManagementSystemActuator.cpp | 12 ++++++------ .../src/model/EnergyManagementSystemActuator.hpp | 4 ++-- .../model/EnergyManagementSystemActuator_Impl.hpp | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 6b2715d9d45..c48632b9c2d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -67,7 +67,7 @@ namespace detail { return EnergyManagementSystemActuator::iddObjectType(); } - ModelObject EnergyManagementSystemActuator_Impl::actuatedComponentName() const { + ModelObject EnergyManagementSystemActuator_Impl::actuatedComponent() const { return this->getTarget(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName)->cast(); //boost::optional result; @@ -83,7 +83,7 @@ namespace detail { return value.get(); } - bool EnergyManagementSystemActuator_Impl::setActuatedComponentName(const ModelObject& modelObject) { + bool EnergyManagementSystemActuator_Impl::setActuatedComponent(const ModelObject& modelObject) { return setPointer(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, modelObject.handle()); } @@ -109,16 +109,16 @@ IddObjectType EnergyManagementSystemActuator::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Actuator); } -ModelObject EnergyManagementSystemActuator::actuatedComponentName() const { - return getImpl()->actuatedComponentName(); +ModelObject EnergyManagementSystemActuator::actuatedComponent() const { + return getImpl()->actuatedComponent(); } std::string EnergyManagementSystemActuator::actuatedComponentControlType() const { return getImpl()->actuatedComponentControlType(); } -bool EnergyManagementSystemActuator::setActuatedComponentName(const ModelObject& modelObject) { - return getImpl()->setActuatedComponentName(modelObject); +bool EnergyManagementSystemActuator::setActuatedComponent(const ModelObject& modelObject) { + return getImpl()->setActuatedComponent(modelObject); } bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index b963fe409de..d39faacaf92 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -49,7 +49,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Getters */ //@{ - ModelObject actuatedComponentName() const; + ModelObject actuatedComponent() const; std::string actuatedComponentControlType() const; @@ -57,7 +57,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Setters */ //@{ - bool setActuatedComponentName(const ModelObject& modelObject); + bool setActuatedComponent(const ModelObject& modelObject); bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp index e5026e277c9..f05e4aee02a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp @@ -30,7 +30,6 @@ namespace detail { /** EnergyManagementSystemActuator_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemActuator.*/ class MODEL_API EnergyManagementSystemActuator_Impl : public ModelObject_Impl { - Q_OBJECT; public: /** @name Constructors and Destructors */ //@{ @@ -61,7 +60,7 @@ namespace detail { /** @name Getters */ //@{ - ModelObject actuatedComponentName() const; + ModelObject actuatedComponent() const; std::string actuatedComponentControlType() const; @@ -69,7 +68,7 @@ namespace detail { /** @name Setters */ //@{ - bool setActuatedComponentName(const ModelObject& modelObject); + bool setActuatedComponent(const ModelObject& modelObject); bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); From 350cff4fa1c723c7d4a009a5f86b18d4ec208936 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 14 Jul 2016 17:43:19 -0600 Subject: [PATCH 013/159] adding in EMS sensor and actuator tests --- openstudiocore/src/model/CMakeLists.txt | 2 + .../EnergyManagementSystemActuator_GTest.cpp | 128 ++++++++++++++++++ .../EnergyManagementSystemSensor_GTest.cpp | 128 ++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index e2e6a9c0b4f..5c324d5e4bf 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1612,6 +1612,8 @@ set(${target_name}_test_src test/ElectricLoadCenterInverterSimple_GTest.cpp test/ElectricLoadCenterInverterLookUpTable_GTest.cpp test/ElectricLoadCenterStorageSimple_GTest.cpp + test/EnergyManagementSystemActuator_GTest.cpp + test/EnergyManagementSystemSensor_GTest.cpp test/EvaporativeCoolerDirectResearchSpecial_GTest.cpp test/EvaporativeCoolerIndirectResearchSpecial_GTest.cpp test/EvaporativeFluidCoolerSingleSpeed_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp new file mode 100644 index 00000000000..f9df4bb17c5 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -0,0 +1,128 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../Lights.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, OutputVariable_ThermalZone) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + for (const ThermalZone& zone : building.thermalZones()) { + + // all possible variables + std::vector variableNames = zone.outputVariableNames(); + EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Electric Power") != variableNames.end()); + EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Radiant Heating Energy") != variableNames.end()); + + // variables actually found + OutputVariableVector variables = zone.outputVariables(); + EXPECT_TRUE(variables.empty()); + } + + // add Zone Lights Electric Power to both zones + OutputVariable lightsElectricPower("Zone Lights Electric Power", model); + EXPECT_EQ("*", lightsElectricPower.keyValue()); + EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); + + // add Zone Lights Radiant Heating Energy to only zone1 + OutputVariable lightsRadiantHeatGain("Zone Lights Radiant Heating Energy", model); + EXPECT_TRUE(lightsRadiantHeatGain.setKeyValue(zone1.name().get())); + EXPECT_EQ(zone1.name().get(), lightsRadiantHeatGain.keyValue()); + EXPECT_EQ("Zone Lights Radiant Heating Energy", lightsRadiantHeatGain.variableName()); + + ASSERT_EQ(2u, zone1.outputVariables().size()); + if (lightsElectricPower.handle() == zone1.outputVariables()[0].handle()){ + EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[0].handle()); + EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[1].handle()); + }else{ + EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[0].handle()); + EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[1].handle()); + } + + ASSERT_EQ(1u, zone2.outputVariables().size()); + EXPECT_EQ(lightsElectricPower.handle(), zone2.outputVariables()[0].handle()); + +} + +TEST_F(ModelFixture, MapOfAllOutputVariables) +{ + Model model = exampleModel(); + + // map of variable name to output variable + std::map > outputVariableMap; + + // get list of all variable names + for (const ModelObject& modelObject : model.getModelObjects()){ + for (const std::string& variableName : modelObject.outputVariableNames()){ + outputVariableMap[variableName] = boost::none; + } + } + + // add all variables to map, allow only one variable per variable name in this application + for (OutputVariable outputVariable : model.getModelObjects()){ + if (outputVariableMap[outputVariable.variableName()]){ + // already have output variable for this name, then remove this object + outputVariable.remove(); + }else{ + + // make sure that key value is set to '*' + outputVariable.setKeyValue("*"); + + outputVariableMap[outputVariable.variableName()] = outputVariable; + } + } + + // now make an output variable for each variable name + typedef std::pair > MapType; + for (MapType mapVal : outputVariableMap){ + if (!mapVal.second){ + OutputVariable outputVariable(mapVal.first, model); + outputVariable.setReportingFrequency("Hourly"); + outputVariableMap[mapVal.first] = outputVariable; + } + + boost::optional outputVariable = outputVariableMap[mapVal.first]; + ASSERT_TRUE(outputVariable); + } +} diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp new file mode 100644 index 00000000000..f9df4bb17c5 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -0,0 +1,128 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../Lights.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, OutputVariable_ThermalZone) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + for (const ThermalZone& zone : building.thermalZones()) { + + // all possible variables + std::vector variableNames = zone.outputVariableNames(); + EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Electric Power") != variableNames.end()); + EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Radiant Heating Energy") != variableNames.end()); + + // variables actually found + OutputVariableVector variables = zone.outputVariables(); + EXPECT_TRUE(variables.empty()); + } + + // add Zone Lights Electric Power to both zones + OutputVariable lightsElectricPower("Zone Lights Electric Power", model); + EXPECT_EQ("*", lightsElectricPower.keyValue()); + EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); + + // add Zone Lights Radiant Heating Energy to only zone1 + OutputVariable lightsRadiantHeatGain("Zone Lights Radiant Heating Energy", model); + EXPECT_TRUE(lightsRadiantHeatGain.setKeyValue(zone1.name().get())); + EXPECT_EQ(zone1.name().get(), lightsRadiantHeatGain.keyValue()); + EXPECT_EQ("Zone Lights Radiant Heating Energy", lightsRadiantHeatGain.variableName()); + + ASSERT_EQ(2u, zone1.outputVariables().size()); + if (lightsElectricPower.handle() == zone1.outputVariables()[0].handle()){ + EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[0].handle()); + EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[1].handle()); + }else{ + EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[0].handle()); + EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[1].handle()); + } + + ASSERT_EQ(1u, zone2.outputVariables().size()); + EXPECT_EQ(lightsElectricPower.handle(), zone2.outputVariables()[0].handle()); + +} + +TEST_F(ModelFixture, MapOfAllOutputVariables) +{ + Model model = exampleModel(); + + // map of variable name to output variable + std::map > outputVariableMap; + + // get list of all variable names + for (const ModelObject& modelObject : model.getModelObjects()){ + for (const std::string& variableName : modelObject.outputVariableNames()){ + outputVariableMap[variableName] = boost::none; + } + } + + // add all variables to map, allow only one variable per variable name in this application + for (OutputVariable outputVariable : model.getModelObjects()){ + if (outputVariableMap[outputVariable.variableName()]){ + // already have output variable for this name, then remove this object + outputVariable.remove(); + }else{ + + // make sure that key value is set to '*' + outputVariable.setKeyValue("*"); + + outputVariableMap[outputVariable.variableName()] = outputVariable; + } + } + + // now make an output variable for each variable name + typedef std::pair > MapType; + for (MapType mapVal : outputVariableMap){ + if (!mapVal.second){ + OutputVariable outputVariable(mapVal.first, model); + outputVariable.setReportingFrequency("Hourly"); + outputVariableMap[mapVal.first] = outputVariable; + } + + boost::optional outputVariable = outputVariableMap[mapVal.first]; + ASSERT_TRUE(outputVariable); + } +} From e49873d96083242be969417708b63ea858f04b1a Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 15 Jul 2016 15:36:20 -0600 Subject: [PATCH 014/159] getting test files to compile --- .../EnergyManagementSystemActuator_GTest.cpp | 43 +------------------ .../EnergyManagementSystemSensor_GTest.cpp | 43 +------------------ 2 files changed, 2 insertions(+), 84 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index f9df4bb17c5..2aa848aa4d0 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -39,7 +39,7 @@ using namespace openstudio; using namespace openstudio::model; using std::string; -TEST_F(ModelFixture, OutputVariable_ThermalZone) +TEST_F(ModelFixture, EMSActuator_EMSActuator) { Model model; @@ -85,44 +85,3 @@ TEST_F(ModelFixture, OutputVariable_ThermalZone) } -TEST_F(ModelFixture, MapOfAllOutputVariables) -{ - Model model = exampleModel(); - - // map of variable name to output variable - std::map > outputVariableMap; - - // get list of all variable names - for (const ModelObject& modelObject : model.getModelObjects()){ - for (const std::string& variableName : modelObject.outputVariableNames()){ - outputVariableMap[variableName] = boost::none; - } - } - - // add all variables to map, allow only one variable per variable name in this application - for (OutputVariable outputVariable : model.getModelObjects()){ - if (outputVariableMap[outputVariable.variableName()]){ - // already have output variable for this name, then remove this object - outputVariable.remove(); - }else{ - - // make sure that key value is set to '*' - outputVariable.setKeyValue("*"); - - outputVariableMap[outputVariable.variableName()] = outputVariable; - } - } - - // now make an output variable for each variable name - typedef std::pair > MapType; - for (MapType mapVal : outputVariableMap){ - if (!mapVal.second){ - OutputVariable outputVariable(mapVal.first, model); - outputVariable.setReportingFrequency("Hourly"); - outputVariableMap[mapVal.first] = outputVariable; - } - - boost::optional outputVariable = outputVariableMap[mapVal.first]; - ASSERT_TRUE(outputVariable); - } -} diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index f9df4bb17c5..72ab807cf4d 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -39,7 +39,7 @@ using namespace openstudio; using namespace openstudio::model; using std::string; -TEST_F(ModelFixture, OutputVariable_ThermalZone) +TEST_F(ModelFixture, EMSSensor_EMSSensor) { Model model; @@ -85,44 +85,3 @@ TEST_F(ModelFixture, OutputVariable_ThermalZone) } -TEST_F(ModelFixture, MapOfAllOutputVariables) -{ - Model model = exampleModel(); - - // map of variable name to output variable - std::map > outputVariableMap; - - // get list of all variable names - for (const ModelObject& modelObject : model.getModelObjects()){ - for (const std::string& variableName : modelObject.outputVariableNames()){ - outputVariableMap[variableName] = boost::none; - } - } - - // add all variables to map, allow only one variable per variable name in this application - for (OutputVariable outputVariable : model.getModelObjects()){ - if (outputVariableMap[outputVariable.variableName()]){ - // already have output variable for this name, then remove this object - outputVariable.remove(); - }else{ - - // make sure that key value is set to '*' - outputVariable.setKeyValue("*"); - - outputVariableMap[outputVariable.variableName()] = outputVariable; - } - } - - // now make an output variable for each variable name - typedef std::pair > MapType; - for (MapType mapVal : outputVariableMap){ - if (!mapVal.second){ - OutputVariable outputVariable(mapVal.first, model); - outputVariable.setReportingFrequency("Hourly"); - outputVariableMap[mapVal.first] = outputVariable; - } - - boost::optional outputVariable = outputVariableMap[mapVal.first]; - ASSERT_TRUE(outputVariable); - } -} From d40b76d8bad0c6e87f742ad8153f37946fe53d47 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 21 Jul 2016 09:51:06 -0600 Subject: [PATCH 015/159] rename outputVariableorOutputMeterIndexKeyName to keyName --- .../model/EnergyManagementSystemSensor.cpp | 25 ++++++------------- .../model/EnergyManagementSystemSensor.hpp | 6 ++--- .../EnergyManagementSystemSensor_Impl.hpp | 6 ++--- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 3d5b5b8e73a..07bfc36ba10 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -70,8 +70,8 @@ namespace detail { return EnergyManagementSystemSensor::iddObjectType(); } - boost::optional EnergyManagementSystemSensor_Impl::outputVariableorOutputMeterIndexKeyName() const { - return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName,true); + boost::optional EnergyManagementSystemSensor_Impl::keyName() const { + return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, true); } OutputVariable EnergyManagementSystemSensor_Impl::outputVariable() const { @@ -90,13 +90,8 @@ namespace detail { return value.get(); } - void EnergyManagementSystemSensor_Impl::setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName) { - bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, outputVariableorOutputMeterIndexKeyName); - OS_ASSERT(result); - } - - void EnergyManagementSystemSensor_Impl::resetOutputVariableorOutputMeterIndexKeyName() { - bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, ""); + void EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, keyName); OS_ASSERT(result); } @@ -136,8 +131,8 @@ IddObjectType EnergyManagementSystemSensor::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Sensor); } -boost::optional EnergyManagementSystemSensor::outputVariableorOutputMeterIndexKeyName() const { - return getImpl()->outputVariableorOutputMeterIndexKeyName(); +boost::optional EnergyManagementSystemSensor::keyName() const { + return getImpl()->keyName(); } boost::optional EnergyManagementSystemSensor::outputVariable() const { @@ -148,12 +143,8 @@ boost::optional EnergyManagementSystemSensor::outputMeter() const { return getImpl()->outputMeter(); } -void EnergyManagementSystemSensor::setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName) { - getImpl()->setOutputVariableorOutputMeterIndexKeyName(outputVariableorOutputMeterIndexKeyName); -} - -void EnergyManagementSystemSensor::resetOutputVariableorOutputMeterIndexKeyName() { - getImpl()->resetOutputVariableorOutputMeterIndexKeyName(); +void EnergyManagementSystemSensor::setKeyName(const std::string& keyName) { + getImpl()->setKeyName(keyName); } bool EnergyManagementSystemSensor::setOutputVariable(const OutputVariable& outputVariable) { diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index a488fd22289..d5bd0d65475 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -52,7 +52,7 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { /** @name Getters */ //@{ - boost::optional outputVariableorOutputMeterIndexKeyName() const; + boost::optional keyName() const; boost::optional outputVariable() const; boost::optional outputMeter() const; @@ -61,9 +61,7 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { /** @name Setters */ //@{ - void setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName); - - void resetOutputVariableorOutputMeterIndexKeyName(); + void setKeyName(const std::string& keyName); bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index d407365ffa1..8c14d2b0229 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -63,7 +63,7 @@ namespace detail { /** @name Getters */ //@{ - boost::optional outputVariableorOutputMeterIndexKeyName() const; + boost::optional keyName() const; OutputVariable outputVariable() const; OutputMeter outputMeter() const; @@ -72,9 +72,7 @@ namespace detail { /** @name Setters */ //@{ - void setOutputVariableorOutputMeterIndexKeyName(const std::string& outputVariableorOutputMeterIndexKeyName); - - void resetOutputVariableorOutputMeterIndexKeyName(); + void setKeyName(const std::string& keyName); bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); From 64ecdd9c5e3d31f3d45df2d065a15dd7af7995cc Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 21 Jul 2016 10:23:58 -0600 Subject: [PATCH 016/159] remove reset from programCallingManager --- .../EnergyManagementSystemProgramCallingManager.cpp | 9 --------- .../EnergyManagementSystemProgramCallingManager.hpp | 2 -- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 2 -- 3 files changed, 13 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 09aa46cdfe3..0dfb07a754f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -74,11 +74,6 @@ namespace detail { return result; } - void EnergyManagementSystemProgramCallingManager_Impl::resetEnergyPlusModelCallingPoint() { - bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, ""); - OS_ASSERT(result); - } - } // detail EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(const Model& model) @@ -106,10 +101,6 @@ bool EnergyManagementSystemProgramCallingManager::setEnergyPlusModelCallingPoint return getImpl()->setEnergyPlusModelCallingPoint(energyPlusModelCallingPoint); } -void EnergyManagementSystemProgramCallingManager::resetEnergyPlusModelCallingPoint() { - getImpl()->resetEnergyPlusModelCallingPoint(); -} - /// @cond EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index e9a80ae5f9c..17e33bab787 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -61,8 +61,6 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); - void resetEnergyPlusModelCallingPoint(); - // TODO: Handle this object's extensible fields. //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index a06189962dc..71b5ebccdaf 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -70,8 +70,6 @@ namespace detail { bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); - void resetEnergyPlusModelCallingPoint(); - // TODO: Handle this object's extensible fields. //@} From 2383103fc08cb976ce68fa56cd256a7d0971fd15 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 25 Jul 2016 10:19:47 -0600 Subject: [PATCH 017/159] renaming program calling point manager callingPoints --- ...ergyManagementSystemProgramCallingManager.cpp | 16 ++++++++-------- ...ergyManagementSystemProgramCallingManager.hpp | 6 +++--- ...anagementSystemProgramCallingManager_Impl.hpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 0dfb07a754f..7e58bed03fd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -65,12 +65,12 @@ namespace detail { return EnergyManagementSystemProgramCallingManager::iddObjectType(); } - boost::optional EnergyManagementSystemProgramCallingManager_Impl::energyPlusModelCallingPoint() const { + boost::optional EnergyManagementSystemProgramCallingManager_Impl::callingPoint() const { return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint,true); } - bool EnergyManagementSystemProgramCallingManager_Impl::setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint) { - bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, energyPlusModelCallingPoint); + bool EnergyManagementSystemProgramCallingManager_Impl::setCallingPoint(const std::string& callingPoint) { + bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); return result; } @@ -88,17 +88,17 @@ IddObjectType EnergyManagementSystemProgramCallingManager::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); } -std::vector EnergyManagementSystemProgramCallingManager::energyPlusModelCallingPointValues() { +std::vector EnergyManagementSystemProgramCallingManager::validCallingPointValues() { return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); } -boost::optional EnergyManagementSystemProgramCallingManager::energyPlusModelCallingPoint() const { - return getImpl()->energyPlusModelCallingPoint(); +boost::optional EnergyManagementSystemProgramCallingManager::callingPoint() const { + return getImpl()->callingPoint(); } -bool EnergyManagementSystemProgramCallingManager::setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint) { - return getImpl()->setEnergyPlusModelCallingPoint(energyPlusModelCallingPoint); +bool EnergyManagementSystemProgramCallingManager::setCallingPoint(const std::string& callingPoint) { + return getImpl()->setCallingPoint(callingPoint); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 17e33bab787..b3c10609871 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -46,12 +46,12 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject static IddObjectType iddObjectType(); - static std::vector energyPlusModelCallingPointValues(); + static std::vector validCallingPointValues(); /** @name Getters */ //@{ - boost::optional energyPlusModelCallingPoint() const; + boost::optional callingPoint() const; // TODO: Handle this object's extensible fields. @@ -59,7 +59,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject /** @name Setters */ //@{ - bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); + bool setCallingPoint(const std::string& callingPoint); // TODO: Handle this object's extensible fields. diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 71b5ebccdaf..52e912ffcc0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -60,7 +60,7 @@ namespace detail { /** @name Getters */ //@{ - boost::optional energyPlusModelCallingPoint() const; + boost::optional callingPoint() const; // TODO: Handle this object's extensible fields. @@ -68,7 +68,7 @@ namespace detail { /** @name Setters */ //@{ - bool setEnergyPlusModelCallingPoint(const std::string& energyPlusModelCallingPoint); + bool setCallingPoint(const std::string& callingPoint); // TODO: Handle this object's extensible fields. From fcc389d295d6dd963aa64a065d9b6d56a8bfbc41 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 25 Jul 2016 13:48:10 -0600 Subject: [PATCH 018/159] build error --- ...yManagementSystemProgramCallingManager.cpp | 99 +++++++++++++++++++ ...yManagementSystemProgramCallingManager.hpp | 19 ++++ ...gementSystemProgramCallingManager_Impl.hpp | 18 ++++ 3 files changed, 136 insertions(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 7e58bed03fd..41bcd84bd44 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -74,6 +74,69 @@ namespace detail { return result; } + boost::optional> EnergyManagementSystemProgramCallingManager_Impl::programs() const { + //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); + //TODO return vector of program names of type string + std::vector result; + return result; + } + + boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { + //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); + //TODO return string of program at input index + std::string result = std::to_string(index); + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::eraseProgram(int index) { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO erase program at index + bool result = true; + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::erasePrograms() { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO erase all programs in this calling manager + bool result = true; + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(int index) { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO erase program at index + bool result = true; + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::addProgram(const std::string& program) { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO add program to end of vector of programs + bool result = true; + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const std::string& program, int index) { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO add program to end of vector of programs + bool result = true; + return result; + } + + bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO add programs to end of vector of programs + bool result = true; + return result; + } + + boost::optional> EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { + //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); + //TODO return vector of program names of type string + std::vector result; + return result; + } + } // detail EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(const Model& model) @@ -101,6 +164,42 @@ bool EnergyManagementSystemProgramCallingManager::setCallingPoint(const std::str return getImpl()->setCallingPoint(callingPoint); } +boost::optional> EnergyManagementSystemProgramCallingManager::programs() const { + return getImpl()->programs(); +} + +boost::optional EnergyManagementSystemProgramCallingManager::getProgram(int index) const { + return getImpl()->getProgram(index); +} + +bool EnergyManagementSystemProgramCallingManager::eraseProgram(int index) { + return getImpl()->eraseProgram(index); +} + +bool EnergyManagementSystemProgramCallingManager::erasePrograms() { + return getImpl()->erasePrograms(); +} + +bool EnergyManagementSystemProgramCallingManager::insertProgram(int index) { + return getImpl()->insertProgram(index); +} + +bool EnergyManagementSystemProgramCallingManager::addProgram(const std::string& program) { + return getImpl()->addProgram(program); +} + +bool EnergyManagementSystemProgramCallingManager::setProgram(const std::string& program, int index) { + return getImpl()->setProgram(program, index); +} + +bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector& programs) { + return getImpl()->setPrograms(programs); +} + +boost::optional> EnergyManagementSystemProgramCallingManager::nullPrograms() { + return getImpl()->nullPrograms(); +} + /// @cond EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index b3c10609871..5de92c2e7f5 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -53,6 +53,12 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject boost::optional callingPoint() const; + boost::optional> programs() const; + + boost::optional getProgram(int index) const; + + boost::optional> nullPrograms() const; + // TODO: Handle this object's extensible fields. //@} @@ -61,6 +67,19 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setCallingPoint(const std::string& callingPoint); + bool eraseProgram(int index); + + bool erasePrograms(); + + bool insertProgram(int index); + + bool addProgram(const std::string& program); + + bool setProgram(const std::string& program, int index); + + bool setPrograms(const std::vector& programs); + + // TODO: Handle this object's extensible fields. //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 52e912ffcc0..d0425082465 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -62,6 +62,12 @@ namespace detail { boost::optional callingPoint() const; + boost::optional> programs() const; + + boost::optional getProgram(int index) const; + + boost::optional> nullPrograms() const; + // TODO: Handle this object's extensible fields. //@} @@ -70,6 +76,18 @@ namespace detail { bool setCallingPoint(const std::string& callingPoint); + bool eraseProgram(int index); + + bool erasePrograms(); + + bool insertProgram(int index); + + bool addProgram(const std::string& program); + + bool setProgram(const std::string& program, int index); + + bool setPrograms(const std::vector& programs); + // TODO: Handle this object's extensible fields. //@} From 59115e3f338395cd4f060e29fbca3104dd886373 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 25 Jul 2016 14:12:31 -0600 Subject: [PATCH 019/159] ProgramCallingManager stubbed out --- ...ergyManagementSystemProgramCallingManager.cpp | 16 +++++++++++++--- ...ergyManagementSystemProgramCallingManager.hpp | 4 +++- ...anagementSystemProgramCallingManager_Impl.hpp | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 41bcd84bd44..c8ce52d2b72 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -130,13 +130,19 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { + std::vector EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); - //TODO return vector of program names of type string + //TODO return vector of indices of null programs in the program vector std::vector result; return result; } + bool EnergyManagementSystemProgramCallingManager_Impl::removeNullPrograms() { + //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); + //TODO remove any null entries in the vector of programs + bool result = true; + return result; + } } // detail EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(const Model& model) @@ -196,10 +202,14 @@ bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector< return getImpl()->setPrograms(programs); } -boost::optional> EnergyManagementSystemProgramCallingManager::nullPrograms() { +std::vector EnergyManagementSystemProgramCallingManager::nullPrograms() const { return getImpl()->nullPrograms(); } +bool EnergyManagementSystemProgramCallingManager::removeNullPrograms() { + return getImpl()->removeNullPrograms(); +} + /// @cond EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 5de92c2e7f5..c4cf5c0d12b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -57,7 +57,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject boost::optional getProgram(int index) const; - boost::optional> nullPrograms() const; + std::vector nullPrograms() const; // TODO: Handle this object's extensible fields. @@ -79,6 +79,8 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setPrograms(const std::vector& programs); + bool removeNullPrograms(); + // TODO: Handle this object's extensible fields. diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index d0425082465..e361d0fd19e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -66,7 +66,7 @@ namespace detail { boost::optional getProgram(int index) const; - boost::optional> nullPrograms() const; + std::vector nullPrograms() const; // TODO: Handle this object's extensible fields. @@ -88,6 +88,8 @@ namespace detail { bool setPrograms(const std::vector& programs); + bool removeNullPrograms(); + // TODO: Handle this object's extensible fields. //@} From 943f76ecae054959f3c47a3abdd007f0e6e7970e Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 25 Jul 2016 16:26:24 -0600 Subject: [PATCH 020/159] stubbing out EMS Program --- .../model/EnergyManagementSystemProgram.cpp | 77 +++++++++++++++++++ .../model/EnergyManagementSystemProgram.hpp | 14 ++++ .../EnergyManagementSystemProgram_Impl.hpp | 15 ++++ 3 files changed, 106 insertions(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 4faa6e2c3f3..0586f213fba 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -64,6 +64,55 @@ namespace detail { return EnergyManagementSystemProgram::iddObjectType(); } + boost::optional EnergyManagementSystemProgram_Impl::body() const { + //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); + //TODO return body of program + std::string result; + return result; + } + + bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { + //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); + //TODO set body of program to input string + bool result = true; + return result; + } + + bool EnergyManagementSystemProgram_Impl::addLine(const std::string& line) { + //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); + //TODO add line to end of program body + bool result = true; + return result; + } + + boost::optional> EnergyManagementSystemProgram_Impl::lines() const { + //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); + //TODO return lines from body + std::vector result; + return result; + } + + bool EnergyManagementSystemProgram_Impl::setLines(const std::vector& lines) { + //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); + //TODO set body of program to input vector of strings + bool result = true; + return result; + } + + boost::optional> EnergyManagementSystemProgram_Impl::referencedObjects() const { + //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); + //TODO return vector of model objects that are referenced in program + std::vector result; + return result; + } + + boost::optional> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { + //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); + //TODO return vector of body lines that contain missing uid strings for invalid referenced objects + std::vector result; + return result; + } + } // detail EnergyManagementSystemProgram::EnergyManagementSystemProgram(const Model& model) @@ -78,6 +127,34 @@ IddObjectType EnergyManagementSystemProgram::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Program); } +boost::optional EnergyManagementSystemProgram::body() const { + return getImpl()->body(); +} + +bool EnergyManagementSystemProgram::setBody(const std::string& body) { + return getImpl()->setBody(body); +} + +bool EnergyManagementSystemProgram::addLine(const std::string& line) { + return getImpl()->addLine(line); +} + +boost::optional> EnergyManagementSystemProgram::lines() const { + return getImpl()->lines(); +} + +bool EnergyManagementSystemProgram::setLines(const std::vector& lines) { + return getImpl()->setLines(lines); +} + +boost::optional> EnergyManagementSystemProgram::referencedObjects() const { + return getImpl()->referencedObjects(); +} + +boost::optional> EnergyManagementSystemProgram::invalidReferencedObjects() const { + return getImpl()->invalidReferencedObjects(); +} + /// @cond EnergyManagementSystemProgram::EnergyManagementSystemProgram(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 41e976db873..0e8d2330fed 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -51,12 +51,26 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { // TODO: Handle this object's extensible fields. + boost::optional body() const; + + boost::optional> lines() const; + + boost::optional> referencedObjects() const; + + boost::optional> invalidReferencedObjects() const; + //@} /** @name Setters */ //@{ // TODO: Handle this object's extensible fields. + bool setBody(const std::string& body); + + bool addLine(const std::string& body); + + bool setLines(const std::vector& body); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index 63189104b33..d99b4d29f60 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -62,12 +62,27 @@ namespace detail { // TODO: Handle this object's extensible fields. + boost::optional body() const; + + boost::optional> lines() const; + + boost::optional> referencedObjects() const; + + boost::optional> invalidReferencedObjects() const; + + //@} /** @name Setters */ //@{ // TODO: Handle this object's extensible fields. + bool setBody(const std::string& body); + + bool addLine(const std::string& body); + + bool setLines(const std::vector& body); + //@} /** @name Other */ //@{ From 9f53f3806cb1927f40750177da8bdcf1adb61111 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Jul 2016 09:40:08 -0600 Subject: [PATCH 021/159] change .insertProgram to take Program --- .../model/EnergyManagementSystemProgramCallingManager.cpp | 8 +++++--- .../model/EnergyManagementSystemProgramCallingManager.hpp | 3 ++- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index c8ce52d2b72..9f2db4fce64 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -19,6 +19,8 @@ #include "EnergyManagementSystemProgramCallingManager.hpp" #include "EnergyManagementSystemProgramCallingManager_Impl.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" #include #include @@ -102,7 +104,7 @@ namespace detail { return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(int index) { + bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, int index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO erase program at index bool result = true; @@ -186,8 +188,8 @@ bool EnergyManagementSystemProgramCallingManager::erasePrograms() { return getImpl()->erasePrograms(); } -bool EnergyManagementSystemProgramCallingManager::insertProgram(int index) { - return getImpl()->insertProgram(index); +bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyManagementSystemProgram& program, int index) { + return getImpl()->insertProgram(program, index); } bool EnergyManagementSystemProgramCallingManager::addProgram(const std::string& program) { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index c4cf5c0d12b..3aa6683d382 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -22,6 +22,7 @@ #include #include "ModelObject.hpp" +#include "EnergyManagementSystemProgram.hpp" namespace openstudio { namespace model { @@ -71,7 +72,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool erasePrograms(); - bool insertProgram(int index); + bool insertProgram(const EnergyManagementSystemProgram& program, int index); bool addProgram(const std::string& program); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index e361d0fd19e..d633aa1d3c2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -22,6 +22,7 @@ #include #include "ModelObject_Impl.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" namespace openstudio { namespace model { @@ -80,7 +81,7 @@ namespace detail { bool erasePrograms(); - bool insertProgram(int index); + bool insertProgram(const EnergyManagementSystemProgram& program, int index); bool addProgram(const std::string& program); From ba1a918fcee22b0b0c0caed3bfc6d9a2e419b4f1 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Jul 2016 10:32:40 -0600 Subject: [PATCH 022/159] changing strings to programs --- ...yManagementSystemProgramCallingManager.cpp | 21 ++++++++++--------- ...yManagementSystemProgramCallingManager.hpp | 8 +++---- ...gementSystemProgramCallingManager_Impl.hpp | 8 +++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 9f2db4fce64..d8c6f0a9a2c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -83,10 +83,11 @@ namespace detail { return result; } - boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { + EnergyManagementSystemProgram EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); - //TODO return string of program at input index - std::string result = std::to_string(index); + //TODO return program at input index + EnergyManagementSystemProgram result; + //std::string index_string = std::to_string(index); return result; } @@ -111,21 +112,21 @@ namespace detail { return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::addProgram(const std::string& program) { + bool EnergyManagementSystemProgramCallingManager_Impl::addProgram(const EnergyManagementSystemProgram& program) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO add program to end of vector of programs bool result = true; return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const std::string& program, int index) { + bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const EnergyManagementSystemProgram& program, int index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO add program to end of vector of programs bool result = true; return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { + bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO add programs to end of vector of programs bool result = true; @@ -176,7 +177,7 @@ boost::optional> EnergyManagementSystemProgramCallingMa return getImpl()->programs(); } -boost::optional EnergyManagementSystemProgramCallingManager::getProgram(int index) const { +EnergyManagementSystemProgram EnergyManagementSystemProgramCallingManager::getProgram(int index) const { return getImpl()->getProgram(index); } @@ -192,15 +193,15 @@ bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyMana return getImpl()->insertProgram(program, index); } -bool EnergyManagementSystemProgramCallingManager::addProgram(const std::string& program) { +bool EnergyManagementSystemProgramCallingManager::addProgram(const EnergyManagementSystemProgram& program) { return getImpl()->addProgram(program); } -bool EnergyManagementSystemProgramCallingManager::setProgram(const std::string& program, int index) { +bool EnergyManagementSystemProgramCallingManager::setProgram(const EnergyManagementSystemProgram& program, int index) { return getImpl()->setProgram(program, index); } -bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector& programs) { +bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector& programs) { return getImpl()->setPrograms(programs); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 3aa6683d382..581b48d62a0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -56,7 +56,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject boost::optional> programs() const; - boost::optional getProgram(int index) const; + EnergyManagementSystemProgram getProgram(int index) const; std::vector nullPrograms() const; @@ -74,11 +74,11 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool insertProgram(const EnergyManagementSystemProgram& program, int index); - bool addProgram(const std::string& program); + bool addProgram(const EnergyManagementSystemProgram& program); - bool setProgram(const std::string& program, int index); + bool setProgram(const EnergyManagementSystemProgram& program, int index); - bool setPrograms(const std::vector& programs); + bool setPrograms(const std::vector& programs); bool removeNullPrograms(); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index d633aa1d3c2..fc9189e9632 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -65,7 +65,7 @@ namespace detail { boost::optional> programs() const; - boost::optional getProgram(int index) const; + EnergyManagementSystemProgram getProgram(int index) const; std::vector nullPrograms() const; @@ -83,11 +83,11 @@ namespace detail { bool insertProgram(const EnergyManagementSystemProgram& program, int index); - bool addProgram(const std::string& program); + bool addProgram(const EnergyManagementSystemProgram& program); - bool setProgram(const std::string& program, int index); + bool setProgram(const EnergyManagementSystemProgram& program, int index); - bool setPrograms(const std::vector& programs); + bool setPrograms(const std::vector& programs); bool removeNullPrograms(); From 1edf85af4e35d7a3499721782790ce7c288fc7c4 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Jul 2016 11:07:42 -0600 Subject: [PATCH 023/159] adding program as a return type --- .../src/model/EnergyManagementSystemProgram.cpp | 6 +++--- .../src/model/EnergyManagementSystemProgram.hpp | 2 +- .../EnergyManagementSystemProgramCallingManager.cpp | 12 ++++++------ .../EnergyManagementSystemProgramCallingManager.hpp | 4 ++-- ...rgyManagementSystemProgramCallingManager_Impl.hpp | 4 ++-- .../src/model/EnergyManagementSystemProgram_Impl.hpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 0586f213fba..cc330728d4c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -99,10 +99,10 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgram_Impl::referencedObjects() const { + boost::optional> EnergyManagementSystemProgram_Impl::referencedObjects() const { //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); //TODO return vector of model objects that are referenced in program - std::vector result; + std::vector result; return result; } @@ -147,7 +147,7 @@ bool EnergyManagementSystemProgram::setLines(const std::vector& lin return getImpl()->setLines(lines); } -boost::optional> EnergyManagementSystemProgram::referencedObjects() const { +boost::optional> EnergyManagementSystemProgram::referencedObjects() const { return getImpl()->referencedObjects(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 0e8d2330fed..4d0f864571d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -55,7 +55,7 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { boost::optional> lines() const; - boost::optional> referencedObjects() const; + boost::optional> referencedObjects() const; boost::optional> invalidReferencedObjects() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index d8c6f0a9a2c..d81bd6b892b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -76,17 +76,17 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgramCallingManager_Impl::programs() const { + boost::optional> EnergyManagementSystemProgramCallingManager_Impl::programs() const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); //TODO return vector of program names of type string - std::vector result; + boost::optional> result; return result; } - EnergyManagementSystemProgram EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { + boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); //TODO return program at input index - EnergyManagementSystemProgram result; + boost::optional result; //std::string index_string = std::to_string(index); return result; } @@ -173,11 +173,11 @@ bool EnergyManagementSystemProgramCallingManager::setCallingPoint(const std::str return getImpl()->setCallingPoint(callingPoint); } -boost::optional> EnergyManagementSystemProgramCallingManager::programs() const { +boost::optional> EnergyManagementSystemProgramCallingManager::programs() const { return getImpl()->programs(); } -EnergyManagementSystemProgram EnergyManagementSystemProgramCallingManager::getProgram(int index) const { +boost::optional EnergyManagementSystemProgramCallingManager::getProgram(int index) const { return getImpl()->getProgram(index); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 581b48d62a0..c48b43465da 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -54,9 +54,9 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject boost::optional callingPoint() const; - boost::optional> programs() const; + boost::optional> programs() const; - EnergyManagementSystemProgram getProgram(int index) const; + boost::optional getProgram(int index) const; std::vector nullPrograms() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index fc9189e9632..7d79adab23d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -63,9 +63,9 @@ namespace detail { boost::optional callingPoint() const; - boost::optional> programs() const; + boost::optional> programs() const; - EnergyManagementSystemProgram getProgram(int index) const; + boost::optional getProgram(int index) const; std::vector nullPrograms() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index d99b4d29f60..ee9a00a2f96 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -66,7 +66,7 @@ namespace detail { boost::optional> lines() const; - boost::optional> referencedObjects() const; + boost::optional> referencedObjects() const; boost::optional> invalidReferencedObjects() const; From 0bbb7d1e572ca45e1a1646f33fe2b7a285bd456c Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 26 Jul 2016 16:58:22 -0600 Subject: [PATCH 024/159] updating return types --- .../src/model/EnergyManagementSystemSensor.cpp | 11 ++++++----- .../src/model/EnergyManagementSystemSensor.hpp | 10 +++++++--- .../src/model/EnergyManagementSystemSensor_Impl.hpp | 13 +++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 07bfc36ba10..8bf36447836 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -74,7 +74,7 @@ namespace detail { return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, true); } - OutputVariable EnergyManagementSystemSensor_Impl::outputVariable() const { + boost::optional EnergyManagementSystemSensor_Impl::outputVariable() const { boost::optional value = optionalOutputVariable(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); @@ -82,7 +82,7 @@ namespace detail { return value.get(); } - OutputMeter EnergyManagementSystemSensor_Impl::outputMeter() const { + boost::optional EnergyManagementSystemSensor_Impl::outputMeter() const { boost::optional value = optionalOutputMeter(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); @@ -90,9 +90,10 @@ namespace detail { return value.get(); } - void EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { + bool EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, keyName); OS_ASSERT(result); + return result; } bool EnergyManagementSystemSensor_Impl::setOutputVariable(const OutputVariable& outputVariable) { @@ -143,8 +144,8 @@ boost::optional EnergyManagementSystemSensor::outputMeter() const { return getImpl()->outputMeter(); } -void EnergyManagementSystemSensor::setKeyName(const std::string& keyName) { - getImpl()->setKeyName(keyName); +bool EnergyManagementSystemSensor::setKeyName(const std::string& keyName) { + return getImpl()->setKeyName(keyName); } bool EnergyManagementSystemSensor::setOutputVariable(const OutputVariable& outputVariable) { diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index d5bd0d65475..9429627e816 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -22,6 +22,10 @@ #include #include "ModelObject.hpp" +#include "OutputVariable.hpp" +#include "OutputVariable_Impl.hpp" +#include "OutputMeter.hpp" +#include "OutputMeter_Impl.hpp" namespace openstudio { namespace model { @@ -54,14 +58,14 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { boost::optional keyName() const; - boost::optional outputVariable() const; - boost::optional outputMeter() const; + boost::optional outputVariable() const; + boost::optional outputMeter() const; //@} /** @name Setters */ //@{ - void setKeyName(const std::string& keyName); + bool setKeyName(const std::string& keyName); bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 8c14d2b0229..ab92210caaa 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -22,12 +22,17 @@ #include #include "ModelObject_Impl.hpp" +#include "OutputVariable.hpp" +#include "OutputVariable_Impl.hpp" +#include "OutputMeter.hpp" +#include "OutputMeter_Impl.hpp" namespace openstudio { namespace model { // TODO: Check the following class names against object getters and setters. -class OutputVariableMeter; +class OutputVariable; +class OutputMeter; namespace detail { @@ -65,14 +70,14 @@ namespace detail { boost::optional keyName() const; - OutputVariable outputVariable() const; - OutputMeter outputMeter() const; + boost::optional outputVariable() const; + boost::optional outputMeter() const; //@} /** @name Setters */ //@{ - void setKeyName(const std::string& keyName); + bool setKeyName(const std::string& keyName); bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); From d7ec21cae196f5faf4d7512ea0f46495c40f58e4 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 13:16:55 -0600 Subject: [PATCH 025/159] clean up --- openstudiocore/src/model/EnergyManagementSystemSensor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 8bf36447836..abb502ae8e4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -124,7 +124,6 @@ EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model) // TODO: Appropriately handle the following required object-list fields. // OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName bool ok = true; - // ok = setOutputVariableorOutputMeter(); OS_ASSERT(ok); } From 59dce8db92631b55d043917206bee96a1948ea02 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 13:21:54 -0600 Subject: [PATCH 026/159] remove optional from callingmanager return type --- .../model/EnergyManagementSystemProgramCallingManager.cpp | 6 +++--- .../model/EnergyManagementSystemProgramCallingManager.hpp | 2 +- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index d81bd6b892b..e13ba8cd578 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -76,10 +76,10 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgramCallingManager_Impl::programs() const { + std::vector EnergyManagementSystemProgramCallingManager_Impl::programs() const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); //TODO return vector of program names of type string - boost::optional> result; + std::vector result; return result; } @@ -173,7 +173,7 @@ bool EnergyManagementSystemProgramCallingManager::setCallingPoint(const std::str return getImpl()->setCallingPoint(callingPoint); } -boost::optional> EnergyManagementSystemProgramCallingManager::programs() const { +std::vector EnergyManagementSystemProgramCallingManager::programs() const { return getImpl()->programs(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index c48b43465da..e6f4f444d83 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -54,7 +54,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject boost::optional callingPoint() const; - boost::optional> programs() const; + std::vector programs() const; boost::optional getProgram(int index) const; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 7d79adab23d..887543e040f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -63,7 +63,7 @@ namespace detail { boost::optional callingPoint() const; - boost::optional> programs() const; + std::vector programs() const; boost::optional getProgram(int index) const; From c6d75c1575aeb852ae88d51435273c04dc519132 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 14:17:11 -0600 Subject: [PATCH 027/159] change int to unsigned for index --- ...yManagementSystemProgramCallingManager.cpp | 22 +++++++++---------- ...yManagementSystemProgramCallingManager.hpp | 10 ++++----- ...gementSystemProgramCallingManager_Impl.hpp | 10 ++++----- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index e13ba8cd578..3cea3729f88 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -83,7 +83,7 @@ namespace detail { return result; } - boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(int index) const { + boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(unsigned index) const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); //TODO return program at input index boost::optional result; @@ -91,7 +91,7 @@ namespace detail { return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::eraseProgram(int index) { + bool EnergyManagementSystemProgramCallingManager_Impl::eraseProgram(unsigned index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO erase program at index bool result = true; @@ -105,7 +105,7 @@ namespace detail { return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, int index) { + bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO erase program at index bool result = true; @@ -119,7 +119,7 @@ namespace detail { return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const EnergyManagementSystemProgram& program, int index) { + bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const EnergyManagementSystemProgram& program, unsigned index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); //TODO add program to end of vector of programs bool result = true; @@ -133,10 +133,10 @@ namespace detail { return result; } - std::vector EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { + std::vector EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); //TODO return vector of indices of null programs in the program vector - std::vector result; + std::vector result; return result; } @@ -177,11 +177,11 @@ std::vector EnergyManagementSystemProgramCallingM return getImpl()->programs(); } -boost::optional EnergyManagementSystemProgramCallingManager::getProgram(int index) const { +boost::optional EnergyManagementSystemProgramCallingManager::getProgram(unsigned index) const { return getImpl()->getProgram(index); } -bool EnergyManagementSystemProgramCallingManager::eraseProgram(int index) { +bool EnergyManagementSystemProgramCallingManager::eraseProgram(unsigned index) { return getImpl()->eraseProgram(index); } @@ -189,7 +189,7 @@ bool EnergyManagementSystemProgramCallingManager::erasePrograms() { return getImpl()->erasePrograms(); } -bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyManagementSystemProgram& program, int index) { +bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { return getImpl()->insertProgram(program, index); } @@ -197,7 +197,7 @@ bool EnergyManagementSystemProgramCallingManager::addProgram(const EnergyManagem return getImpl()->addProgram(program); } -bool EnergyManagementSystemProgramCallingManager::setProgram(const EnergyManagementSystemProgram& program, int index) { +bool EnergyManagementSystemProgramCallingManager::setProgram(const EnergyManagementSystemProgram& program, unsigned index) { return getImpl()->setProgram(program, index); } @@ -205,7 +205,7 @@ bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector< return getImpl()->setPrograms(programs); } -std::vector EnergyManagementSystemProgramCallingManager::nullPrograms() const { +std::vector EnergyManagementSystemProgramCallingManager::nullPrograms() const { return getImpl()->nullPrograms(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index e6f4f444d83..8c1a14b7454 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -56,9 +56,9 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject std::vector programs() const; - boost::optional getProgram(int index) const; + boost::optional getProgram(unsigned index) const; - std::vector nullPrograms() const; + std::vector nullPrograms() const; // TODO: Handle this object's extensible fields. @@ -68,15 +68,15 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setCallingPoint(const std::string& callingPoint); - bool eraseProgram(int index); + bool eraseProgram(unsigned index); bool erasePrograms(); - bool insertProgram(const EnergyManagementSystemProgram& program, int index); + bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); bool addProgram(const EnergyManagementSystemProgram& program); - bool setProgram(const EnergyManagementSystemProgram& program, int index); + bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); bool setPrograms(const std::vector& programs); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 887543e040f..ab04771b61a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -65,9 +65,9 @@ namespace detail { std::vector programs() const; - boost::optional getProgram(int index) const; + boost::optional getProgram(unsigned index) const; - std::vector nullPrograms() const; + std::vector nullPrograms() const; // TODO: Handle this object's extensible fields. @@ -77,15 +77,15 @@ namespace detail { bool setCallingPoint(const std::string& callingPoint); - bool eraseProgram(int index); + bool eraseProgram(unsigned index); bool erasePrograms(); - bool insertProgram(const EnergyManagementSystemProgram& program, int index); + bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); bool addProgram(const EnergyManagementSystemProgram& program); - bool setProgram(const EnergyManagementSystemProgram& program, int index); + bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); bool setPrograms(const std::vector& programs); From 4889922999ee84ac7a83d3f386f5305b34a06085 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 14:40:25 -0600 Subject: [PATCH 028/159] clean up --- .../src/model/EnergyManagementSystemActuator.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index c48632b9c2d..ff6046a6cf6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -70,11 +70,6 @@ namespace detail { ModelObject EnergyManagementSystemActuator_Impl::actuatedComponent() const { return this->getTarget(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName)->cast(); - //boost::optional result; - //result = this->actuatedComponentName(); - //OS_ASSERT(result); - //return result.get(); - //return OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName(); } std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const { @@ -99,10 +94,6 @@ EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // setActuatedComponentName(); - // setActuatedComponentControlType(); } IddObjectType EnergyManagementSystemActuator::iddObjectType() { From f584d97b48a368def46dc7e23b7ad9bf9fd3e956 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 15:14:17 -0600 Subject: [PATCH 029/159] trying to add body to program --- .../src/model/EnergyManagementSystemProgram.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index cc330728d4c..8e727db97b2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -65,10 +65,11 @@ namespace detail { } boost::optional EnergyManagementSystemProgram_Impl::body() const { - //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); - //TODO return body of program - std::string result; - return result; + //TODO return program body as string + //Doesnt there need to be a loop here? + boost::optional value = getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); + OS_ASSERT(value); + return value.get(); } bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { From d02e4a70d9bbd9bb3c74cafed48bf2eb11332d90 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 15:25:53 -0600 Subject: [PATCH 030/159] trying to get the programs --- .../model/EnergyManagementSystemProgramCallingManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 3cea3729f88..bc0a2400752 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -77,9 +77,12 @@ namespace detail { } std::vector EnergyManagementSystemProgramCallingManager_Impl::programs() const { - //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); - //TODO return vector of program names of type string + //TODO return vector of programs + //TODO loop through programs? std::vector result; + EnergyManagementSystemProgram program = this->getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName)->cast(); + result.push_back(program); + return result; } From 0db201184d855660007a4252f15c4d227c5f5ed1 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 16:15:43 -0600 Subject: [PATCH 031/159] adding loop for getting program --- .../model/EnergyManagementSystemProgram.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 8e727db97b2..9896f02671c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -25,6 +25,8 @@ #include "../utilities/core/Assert.hpp" +#include "ModelExtensibleGroup.hpp" + namespace openstudio { namespace model { @@ -66,10 +68,21 @@ namespace detail { boost::optional EnergyManagementSystemProgram_Impl::body() const { //TODO return program body as string - //Doesnt there need to be a loop here? - boost::optional value = getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); - OS_ASSERT(value); - return value.get(); + //Doesn't there need to be a loop here? + //boost::optional value = getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); + //OS_ASSERT(value); + //return value.get(); + // loop through extensible groups + std::string body; + auto groups = extensibleGroups(); + for (auto group = groups.begin(); group != groups.end(); ++group) { + const auto & line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); + OS_ASSERT(line); + body += line.get(); + } + + return body; + } bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { From eb6f40d5a0e9b2b7e1feb92991e6994ab24fb3ff Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 27 Jul 2016 16:57:01 -0600 Subject: [PATCH 032/159] loop through extensible groups for programCallingManager program --- ...gyManagementSystemProgramCallingManager.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index bc0a2400752..61a64f53545 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -28,6 +28,8 @@ #include "../utilities/core/Assert.hpp" +#include "ModelExtensibleGroup.hpp" + namespace openstudio { namespace model { @@ -79,10 +81,20 @@ namespace detail { std::vector EnergyManagementSystemProgramCallingManager_Impl::programs() const { //TODO return vector of programs //TODO loop through programs? + //EnergyManagementSystemProgram program = this->getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName)->cast(); + + // loop through extensible groups std::vector result; - EnergyManagementSystemProgram program = this->getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName)->cast(); - result.push_back(program); - + auto groups = extensibleGroups(); + + for (const auto & elem : groups) { + WorkspaceExtensibleGroup group = elem.cast(); + boost::optional wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); + if (wo){ + EnergyManagementSystemProgram program = wo->cast(); + result.push_back(program); + } + } return result; } From 64fa46f043174d84ac5d7bf6accde31309d3556e Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 29 Jul 2016 13:15:03 -0600 Subject: [PATCH 033/159] adding in extensible groups for program manager --- ...yManagementSystemProgramCallingManager.cpp | 76 +++++++++++++------ ...yManagementSystemProgramCallingManager.hpp | 2 +- ...gementSystemProgramCallingManager_Impl.hpp | 2 +- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 61a64f53545..0b0462e9b6f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -79,14 +79,10 @@ namespace detail { } std::vector EnergyManagementSystemProgramCallingManager_Impl::programs() const { - //TODO return vector of programs - //TODO loop through programs? - //EnergyManagementSystemProgram program = this->getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName)->cast(); - - // loop through extensible groups + // loop through extensible groups and return vector of programs std::vector result; auto groups = extensibleGroups(); - + for (const auto & elem : groups) { WorkspaceExtensibleGroup group = elem.cast(); boost::optional wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); @@ -99,25 +95,44 @@ namespace detail { } boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(unsigned index) const { - //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); - //TODO return program at input index + //TODO return program at index boost::optional result; - //std::string index_string = std::to_string(index); + auto groups = extensibleGroups(); + unsigned sizeOfGroup = numExtensibleGroups(); + + //is this < or <= + if ((index <= sizeOfGroup) && (!groups[index].empty())) { + WorkspaceExtensibleGroup group = groups[index].cast(); + boost::optional wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); + if (wo) { + EnergyManagementSystemProgram program = wo->cast(); + result = program; + } + } else { + //assert here? + OS_ASSERT(false); + } return result; } bool EnergyManagementSystemProgramCallingManager_Impl::eraseProgram(unsigned index) { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO erase program at index - bool result = true; + //erase program at index + bool result = false; + auto groups = extensibleGroups(); + unsigned sizeOfGroup = numExtensibleGroups(); + + //is this < or <= + if (index <= sizeOfGroup) { + eraseExtensibleGroup(index); + result = true; + } return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::erasePrograms() { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO erase all programs in this calling manager - bool result = true; - return result; + void EnergyManagementSystemProgramCallingManager_Impl::erasePrograms() { + //erase all programs in this calling manager + clearExtensibleGroups(); + } bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { @@ -128,16 +143,27 @@ namespace detail { } bool EnergyManagementSystemProgramCallingManager_Impl::addProgram(const EnergyManagementSystemProgram& program) { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO add program to end of vector of programs - bool result = true; + //add program to end of vector of programs + bool result = false; + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); return result; } bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const EnergyManagementSystemProgram& program, unsigned index) { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO add program to end of vector of programs - bool result = true; + //add program to {index} of vector of programs + bool result = false; + auto groups = extensibleGroups(); + unsigned sizeOfGroup = numExtensibleGroups(); + if (index <= sizeOfGroup) { + //WorkspaceExtensibleGroup group = getObject().insertExtensibleGroup().cast(); + //result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); + IdfExtensibleGroup idfGroup = insertExtensibleGroup(index, StringVector()); + OS_ASSERT(!idfGroup.empty()); + ModelExtensibleGroup group = idfGroup.cast(); + bool result = group.setPointer(0, program.handle()); + OS_ASSERT(result); + } return result; } @@ -200,8 +226,8 @@ bool EnergyManagementSystemProgramCallingManager::eraseProgram(unsigned index) { return getImpl()->eraseProgram(index); } -bool EnergyManagementSystemProgramCallingManager::erasePrograms() { - return getImpl()->erasePrograms(); +void EnergyManagementSystemProgramCallingManager::erasePrograms() { + getImpl()->erasePrograms(); } bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 8c1a14b7454..376ed497790 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -70,7 +70,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool eraseProgram(unsigned index); - bool erasePrograms(); + void erasePrograms(); bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index ab04771b61a..8a80b5683c4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -79,7 +79,7 @@ namespace detail { bool eraseProgram(unsigned index); - bool erasePrograms(); + void erasePrograms(); bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); From d2fd6bb70b010f1d40841916f22e6c9dce57cb47 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 1 Aug 2016 13:52:40 -0600 Subject: [PATCH 034/159] setPrograms --- ...yManagementSystemProgramCallingManager.cpp | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 0b0462e9b6f..882dae544b4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -95,22 +95,18 @@ namespace detail { } boost::optional EnergyManagementSystemProgramCallingManager_Impl::getProgram(unsigned index) const { - //TODO return program at index + //return program at index boost::optional result; auto groups = extensibleGroups(); unsigned sizeOfGroup = numExtensibleGroups(); - //is this < or <= - if ((index <= sizeOfGroup) && (!groups[index].empty())) { + if ((index < sizeOfGroup) && (!groups[index].empty())) { WorkspaceExtensibleGroup group = groups[index].cast(); boost::optional wo = group.getTarget(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); if (wo) { EnergyManagementSystemProgram program = wo->cast(); result = program; } - } else { - //assert here? - OS_ASSERT(false); } return result; } @@ -137,7 +133,7 @@ namespace detail { bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO erase program at index + //TODO what is this method doing? how is it different that setProgram? bool result = true; return result; } @@ -156,8 +152,6 @@ namespace detail { auto groups = extensibleGroups(); unsigned sizeOfGroup = numExtensibleGroups(); if (index <= sizeOfGroup) { - //WorkspaceExtensibleGroup group = getObject().insertExtensibleGroup().cast(); - //result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); IdfExtensibleGroup idfGroup = insertExtensibleGroup(index, StringVector()); OS_ASSERT(!idfGroup.empty()); ModelExtensibleGroup group = idfGroup.cast(); @@ -168,9 +162,21 @@ namespace detail { } bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO add programs to end of vector of programs - bool result = true; + //add programs to end of vector of programs + std::vector ok(programs.size(), false); + bool result = false; + for (auto &program : programs) { + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); + ok.push_back(result); + } + //check if all the programs set true + result = true; + for (int i = 0; i Date: Wed, 3 Aug 2016 10:04:12 -0600 Subject: [PATCH 035/159] programcallingmanager nullprograms --- ...nergyManagementSystemProgramCallingManager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 882dae544b4..388cde21242 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -117,8 +117,7 @@ namespace detail { auto groups = extensibleGroups(); unsigned sizeOfGroup = numExtensibleGroups(); - //is this < or <= - if (index <= sizeOfGroup) { + if (index < sizeOfGroup) { eraseExtensibleGroup(index); result = true; } @@ -181,9 +180,17 @@ namespace detail { } std::vector EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { - //return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, true); - //TODO return vector of indices of null programs in the program vector + //return vector of indices of null programs in the program vector std::vector result; + unsigned i = 0; + auto groups = extensibleGroups(); + unsigned sizeOfGroup = numExtensibleGroups(); + for (auto &group : groups) { + if (group.empty()) { + result.push_back(i); + }; + i++; + } return result; } From c703411d6515bce886ecf7e00f67e926bb084cd4 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 10:26:41 -0600 Subject: [PATCH 036/159] programcallingmanager removeNullPrograms --- ...EnergyManagementSystemProgramCallingManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 388cde21242..0baaed8eb4d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -195,9 +195,17 @@ namespace detail { } bool EnergyManagementSystemProgramCallingManager_Impl::removeNullPrograms() { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO remove any null entries in the vector of programs - bool result = true; + //remove any null entries in the vector of programs + bool result = false; + std::vector nullProgs; + nullProgs = this->nullPrograms(); + + if (!nullProgs.empty()) { + for (int i = 0; i < nullProgs.size(); i++) { + result = this->eraseProgram(i); + }; + }; + return result; } } // detail From dfad490cde1a8bf72746cd366d72f6995061f4c9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 11:11:52 -0600 Subject: [PATCH 037/159] program eraseBody --- .../model/EnergyManagementSystemProgram.cpp | 35 ++++++++++++++----- .../model/EnergyManagementSystemProgram.hpp | 2 ++ .../EnergyManagementSystemProgram_Impl.hpp | 2 ++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 9896f02671c..29d721598bd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -67,12 +67,9 @@ namespace detail { } boost::optional EnergyManagementSystemProgram_Impl::body() const { - //TODO return program body as string - //Doesn't there need to be a loop here? - //boost::optional value = getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); - //OS_ASSERT(value); - //return value.get(); - // loop through extensible groups + //return program body as string + + // loop through extensible groups and add ProgramLine to body string. std::string body; auto groups = extensibleGroups(); for (auto group = groups.begin(); group != groups.end(); ++group) { @@ -86,12 +83,28 @@ namespace detail { } bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { - //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); - //TODO set body of program to input string - bool result = true; + //set body of program to input string + bool result = false; + if (body.empty()) { + return false; + }; + + return result; } + bool EnergyManagementSystemProgram_Impl::eraseBody() { + //erase body of program + bool results = false; + std::vector< std::vector > result; + result = clearExtensibleGroups(); + // if result is not empty, then the group was cleared out since the old values were returned + if (!result.empty()) { + results = true; + }; + return results; + } + bool EnergyManagementSystemProgram_Impl::addLine(const std::string& line) { //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); //TODO add line to end of program body @@ -149,6 +162,10 @@ bool EnergyManagementSystemProgram::setBody(const std::string& body) { return getImpl()->setBody(body); } +bool EnergyManagementSystemProgram::eraseBody() { + return getImpl()->eraseBody(); +} + bool EnergyManagementSystemProgram::addLine(const std::string& line) { return getImpl()->addLine(line); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 4d0f864571d..16b9ab3d8e3 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -67,6 +67,8 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { bool setBody(const std::string& body); + bool eraseBody(); + bool addLine(const std::string& body); bool setLines(const std::vector& body); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index ee9a00a2f96..edd32acc464 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -79,6 +79,8 @@ namespace detail { bool setBody(const std::string& body); + bool eraseBody(); + bool addLine(const std::string& body); bool setLines(const std::vector& body); From 34ab2941194c50f9ca508456aa412edeaf84887f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 14:53:10 -0600 Subject: [PATCH 038/159] program setBody --- .../model/EnergyManagementSystemProgram.cpp | 31 +++++++++++++++++-- .../model/EnergyManagementSystemProgram.hpp | 2 +- .../EnergyManagementSystemProgram_Impl.hpp | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 29d721598bd..0fd435a2407 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -27,6 +27,9 @@ #include "ModelExtensibleGroup.hpp" +#include "../utilities/core/String.hpp" +#include "../utilities/core/StringHelpers.hpp" + namespace openstudio { namespace model { @@ -82,14 +85,38 @@ namespace detail { } - bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { + bool EnergyManagementSystemProgram_Impl::setBody(std::string& body) { //set body of program to input string bool result = false; + //if body string empty then return false if (body.empty()) { return false; }; + //clobber existing body + this->eraseBody(); + + // remove '\r' from the body string + std::string body_minus_r = body; + body_minus_r.erase(std::remove(body.begin(), body.end(), '\r'), body.end()); + + //split the body string on newline characters and insert program line for each string line + std::vector body_minus_nl = splitString(body_minus_r, '\n'); + //add program lines to body + std::vector ok(body_minus_nl.size(), false); + for (int i = 0; i < body_minus_nl.size(); i++) { + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl[i]); + ok.push_back(result); + } + //check if all the programs set true + result = true; + for (int i = 0; i EnergyManagementSystemProgram::body() const { return getImpl()->body(); } -bool EnergyManagementSystemProgram::setBody(const std::string& body) { +bool EnergyManagementSystemProgram::setBody(std::string& body) { return getImpl()->setBody(body); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 16b9ab3d8e3..402d261e7e6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -65,7 +65,7 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { // TODO: Handle this object's extensible fields. - bool setBody(const std::string& body); + bool setBody(std::string& body); bool eraseBody(); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index edd32acc464..e1cec0ee7cd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -77,7 +77,7 @@ namespace detail { // TODO: Handle this object's extensible fields. - bool setBody(const std::string& body); + bool setBody(std::string& body); bool eraseBody(); From 6977010c4b698c452eac240d2b1aac0c127b668f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 16:43:06 -0600 Subject: [PATCH 039/159] program setLines --- .../src/model/EnergyManagementSystemProgram.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 0fd435a2407..4ea7778bd9f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -141,8 +141,20 @@ namespace detail { boost::optional> EnergyManagementSystemProgram_Impl::lines() const { //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); - //TODO return lines from body + //TODO return vector of lines from body std::vector result; + //return program body as string + + // loop through extensible groups and add ProgramLine to vector result. + auto groups = extensibleGroups(); + unsigned i = 0; + for (auto group = groups.begin(); group != groups.end(); ++group) { + const auto & line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); + OS_ASSERT(line); + result[i] += line.get(); + i++; + } + return result; } From 5072727e7cb42d53ab7ae2201b06ad589d4dc777 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 16:58:07 -0600 Subject: [PATCH 040/159] program setLines --- .../model/EnergyManagementSystemProgram.cpp | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 4ea7778bd9f..fbe47ecfe0e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -159,9 +159,37 @@ namespace detail { } bool EnergyManagementSystemProgram_Impl::setLines(const std::vector& lines) { - //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); - //TODO set body of program to input vector of strings - bool result = true; + //set body of program to input vector of strings + bool result = false; + std::string temp; + + //if body string empty then return false + if (lines.empty()) { + return false; + }; + + //clobber existing body + this->eraseBody(); + + // remove '\r' from the body string + //for (int i = 0; i < lines.size(); i++) { + // temp = lines[i]; + // lines[i] = temp.erase(std::remove(lines[i].begin(), lines[i].end(), '\r'), lines[i].end()); + //} + //add program lines to body + std::vector ok(lines.size(), false); + for (int i = 0; i < lines.size(); i++) { + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, lines[i]); + ok.push_back(result); + } + //check if all the programs set true + result = true; + for (int i = 0; i Date: Wed, 3 Aug 2016 17:05:24 -0600 Subject: [PATCH 041/159] program addLine --- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index fbe47ecfe0e..287937155f2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -133,9 +133,10 @@ namespace detail { } bool EnergyManagementSystemProgram_Impl::addLine(const std::string& line) { - //bool result = setString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, body); - //TODO add line to end of program body + //add line to end of program body bool result = true; + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, line); return result; } From a91339b130705e0c8d170931cbbff3a3dec8d496 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 3 Aug 2016 17:10:27 -0600 Subject: [PATCH 042/159] clean up --- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 7 +------ .../model/EnergyManagementSystemProgramCallingManager.cpp | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 287937155f2..4bdb1371906 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -80,9 +80,7 @@ namespace detail { OS_ASSERT(line); body += line.get(); } - return body; - } bool EnergyManagementSystemProgram_Impl::setBody(std::string& body) { @@ -141,10 +139,8 @@ namespace detail { } boost::optional> EnergyManagementSystemProgram_Impl::lines() const { - //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); - //TODO return vector of lines from body + //return vector of lines from body std::vector result; - //return program body as string // loop through extensible groups and add ProgramLine to vector result. auto groups = extensibleGroups(); @@ -155,7 +151,6 @@ namespace detail { result[i] += line.get(); i++; } - return result; } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 0baaed8eb4d..42c16613721 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -127,7 +127,6 @@ namespace detail { void EnergyManagementSystemProgramCallingManager_Impl::erasePrograms() { //erase all programs in this calling manager clearExtensibleGroups(); - } bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { @@ -205,7 +204,6 @@ namespace detail { result = this->eraseProgram(i); }; }; - return result; } } // detail From 13d5895ac1ddf95e25443cfed149da750e020396 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 11 Aug 2016 10:10:38 -0600 Subject: [PATCH 043/159] start at finding uids in the ems program --- .../model/EnergyManagementSystemProgram.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 4bdb1371906..0fabf15b720 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -193,6 +193,27 @@ namespace detail { //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); //TODO return vector of model objects that are referenced in program std::vector result; + + std::vector body; + //test vector + std::string test; + test = "blah"; + body.push_back(test); + test = "set temp = 92093437-80c7-47e2-82bf-015241c60012"; + body.push_back(test); + test = "blah"; + body.push_back(test); + + //assume body is a vector of strings + for (int i = 0; i < body.size(); i++) { + std::vector results = splitString(body[i], ' '); + for (int j = 0; j < results.size(); j++) { + if (results[j].size() == 36) { + std::string possible_uid = results[j]; + //look to see if uid is in the model and return the object + } + } + } return result; } From 94d194ab0e2824cf865b7a4e3c49e41c32725731 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 16 Aug 2016 11:10:56 -0600 Subject: [PATCH 044/159] idd change to actuator name to get pointer assigned correctly --- openstudiocore/resources/model/OpenStudio.idd | 4 +++- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index cc6b3b6d805..897472ccf52 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26384,6 +26384,7 @@ OS:EnergyManagementSystem:Sensor, \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames + \reference AllObjects A3 , \field Output Variable or Output Meter Index Key Name \type alpha \note key name listed here will override key name in Output:Variable or Output:Meter @@ -26404,9 +26405,10 @@ OS:EnergyManagementSystem:Actuator, \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames + \reference AllObjects A3 , \field Actuated Component Name \required-field - \type alpha + \type object-list \object-list AllObjects A4 ; \field Actuated Component Control Type \required-field diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 0fabf15b720..33b4bd7d6c4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -206,6 +206,7 @@ namespace detail { //assume body is a vector of strings for (int i = 0; i < body.size(); i++) { + //split string on whitespaces to isolate possible uids std::vector results = splitString(body[i], ' '); for (int j = 0; j < results.size(); j++) { if (results[j].size() == 36) { From 659b8906238dadbdff2b7bcd9cca3b25faade9d3 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 08:43:18 -0600 Subject: [PATCH 045/159] adding setActuatedComponent to actuator constructor --- openstudiocore/src/model/EnergyManagementSystemActuator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index ff6046a6cf6..a06ad6a8bc0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -94,6 +94,7 @@ EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { OS_ASSERT(getImpl()); + setActuatedComponent(modelObject); } IddObjectType EnergyManagementSystemActuator::iddObjectType() { From 3fdf88f08d73245a03998e1150209242e1a09cba Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 10:51:03 -0600 Subject: [PATCH 046/159] GTests for sensor and actuator --- .../EnergyManagementSystemActuator_GTest.cpp | 54 +++++++------------ .../EnergyManagementSystemSensor_GTest.cpp | 45 ++++------------ 2 files changed, 30 insertions(+), 69 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index 2aa848aa4d0..d65e0f78cd2 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -23,7 +23,10 @@ #include "../Building.hpp" #include "../Building_Impl.hpp" #include "../ThermalZone.hpp" -#include "../Lights.hpp" +#include "../FanConstantVolume.hpp" +#include "../FanConstantVolume_Impl.hpp" +#include "../Schedule.hpp" +#include "../EnergyManagementSystemActuator.hpp" #include "../OutputVariable.hpp" #include "../OutputVariable_Impl.hpp" #include "../Model_Impl.hpp" @@ -48,40 +51,21 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) ThermalZone zone1(model); ThermalZone zone2(model); - for (const ThermalZone& zone : building.thermalZones()) { - - // all possible variables - std::vector variableNames = zone.outputVariableNames(); - EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Electric Power") != variableNames.end()); - EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Radiant Heating Energy") != variableNames.end()); - - // variables actually found - OutputVariableVector variables = zone.outputVariables(); - EXPECT_TRUE(variables.empty()); - } - - // add Zone Lights Electric Power to both zones - OutputVariable lightsElectricPower("Zone Lights Electric Power", model); - EXPECT_EQ("*", lightsElectricPower.keyValue()); - EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); - - // add Zone Lights Radiant Heating Energy to only zone1 - OutputVariable lightsRadiantHeatGain("Zone Lights Radiant Heating Energy", model); - EXPECT_TRUE(lightsRadiantHeatGain.setKeyValue(zone1.name().get())); - EXPECT_EQ(zone1.name().get(), lightsRadiantHeatGain.keyValue()); - EXPECT_EQ("Zone Lights Radiant Heating Energy", lightsRadiantHeatGain.variableName()); - - ASSERT_EQ(2u, zone1.outputVariables().size()); - if (lightsElectricPower.handle() == zone1.outputVariables()[0].handle()){ - EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[0].handle()); - EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[1].handle()); - }else{ - EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[0].handle()); - EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[1].handle()); - } - - ASSERT_EQ(1u, zone2.outputVariables().size()); - EXPECT_EQ(lightsElectricPower.handle(), zone2.outputVariables()[0].handle()); + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); + + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + EXPECT_EQ(fan, fanActuator.actuatedComponent()); + EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 72ab807cf4d..51002b3e3b6 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -23,7 +23,7 @@ #include "../Building.hpp" #include "../Building_Impl.hpp" #include "../ThermalZone.hpp" -#include "../Lights.hpp" +#include "../EnergyManagementSystemSensor.hpp" #include "../OutputVariable.hpp" #include "../OutputVariable_Impl.hpp" #include "../Model_Impl.hpp" @@ -48,40 +48,17 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) ThermalZone zone1(model); ThermalZone zone2(model); - for (const ThermalZone& zone : building.thermalZones()) { + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); - // all possible variables - std::vector variableNames = zone.outputVariableNames(); - EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Electric Power") != variableNames.end()); - EXPECT_TRUE(std::find(variableNames.begin(), variableNames.end(), "Zone Lights Radiant Heating Energy") != variableNames.end()); - - // variables actually found - OutputVariableVector variables = zone.outputVariables(); - EXPECT_TRUE(variables.empty()); - } - - // add Zone Lights Electric Power to both zones - OutputVariable lightsElectricPower("Zone Lights Electric Power", model); - EXPECT_EQ("*", lightsElectricPower.keyValue()); - EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); - - // add Zone Lights Radiant Heating Energy to only zone1 - OutputVariable lightsRadiantHeatGain("Zone Lights Radiant Heating Energy", model); - EXPECT_TRUE(lightsRadiantHeatGain.setKeyValue(zone1.name().get())); - EXPECT_EQ(zone1.name().get(), lightsRadiantHeatGain.keyValue()); - EXPECT_EQ("Zone Lights Radiant Heating Energy", lightsRadiantHeatGain.variableName()); - - ASSERT_EQ(2u, zone1.outputVariables().size()); - if (lightsElectricPower.handle() == zone1.outputVariables()[0].handle()){ - EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[0].handle()); - EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[1].handle()); - }else{ - EXPECT_EQ(lightsRadiantHeatGain.handle(), zone1.outputVariables()[0].handle()); - EXPECT_EQ(lightsElectricPower.handle(), zone1.outputVariables()[1].handle()); - } - - ASSERT_EQ(1u, zone2.outputVariables().size()); - EXPECT_EQ(lightsElectricPower.handle(), zone2.outputVariables()[0].handle()); + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + EXPECT_EQ("OATdb Sensor", OATdbSensor.nameString()); + EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle() ); + EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); } From e05894c5bd29f6e682018186fae29fb9dfc662f3 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 15:45:27 -0600 Subject: [PATCH 047/159] GTest for Program --- .../model/EnergyManagementSystemProgram.cpp | 7 +- .../EnergyManagementSystemActuator_GTest.cpp | 7 +- .../EnergyManagementSystemProgram_GTest.cpp | 84 +++++++++++++++++++ .../EnergyManagementSystemSensor_GTest.cpp | 1 + 4 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 33b4bd7d6c4..113d6fe672d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -30,6 +30,8 @@ #include "../utilities/core/String.hpp" #include "../utilities/core/StringHelpers.hpp" +#include + namespace openstudio { namespace model { @@ -96,7 +98,10 @@ namespace detail { // remove '\r' from the body string std::string body_minus_r = body; - body_minus_r.erase(std::remove(body.begin(), body.end(), '\r'), body.end()); + std::string::size_type pos = 0; // Must initialize + while ((pos = body_minus_r.find("\r", pos)) != std::string::npos) { + body_minus_r.erase(pos, 1); + } //split the body string on newline characters and insert program line for each string line std::vector body_minus_nl = splitString(body_minus_r, '\n'); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index d65e0f78cd2..6312a2ba9e8 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -51,14 +51,11 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) ThermalZone zone1(model); ThermalZone zone2(model); - // add Site Outdoor Air Drybulb Temperature - OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); - EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); - EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); - + // add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); + // add actuator EnergyManagementSystemActuator fanActuator(fan); std::string fanName = fan.name().get() + "Press Actuator"; fanActuator.setName(fanName); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp new file mode 100644 index 00000000000..f7053518edf --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -0,0 +1,84 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../FanConstantVolume.hpp" +#include "../FanConstantVolume_Impl.hpp" +#include "../Schedule.hpp" +#include "../EnergyManagementSystemActuator.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemProgram.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSProgram_EMSProgram) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + + //add program + EnergyManagementSystemProgram fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_1.setName(programName); + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + fan_program_1.setBody(fan_program_1_body); + fan_program_1.lines().get(); + EXPECT_EQ(2, fan_program_1.lines().get().size()); +} + diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 51002b3e3b6..7d0b6e91d86 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -53,6 +53,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); + // add sensor EnergyManagementSystemSensor OATdbSensor(model); OATdbSensor.setName("OATdb Sensor"); OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); From e3f5a03985a6e61e95387b220ce54cce26834419 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 17:10:15 -0600 Subject: [PATCH 048/159] update addLines, addLine, addBody to remove \r\n's Program passes tests --- .../model/EnergyManagementSystemProgram.cpp | 31 ++++---- .../EnergyManagementSystemProgram_GTest.cpp | 71 ++++++++++++++++++- 2 files changed, 87 insertions(+), 15 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 113d6fe672d..94f76d4b4b6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -110,7 +110,7 @@ namespace detail { std::vector ok(body_minus_nl.size(), false); for (int i = 0; i < body_minus_nl.size(); i++) { WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl[i]); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl[i] + '\n'); ok.push_back(result); } //check if all the programs set true @@ -138,8 +138,21 @@ namespace detail { bool EnergyManagementSystemProgram_Impl::addLine(const std::string& line) { //add line to end of program body bool result = true; + + // remove '\r' from the line string + std::string line_rn = line; + std::string::size_type pos = 0; // Must initialize + while ((pos = line_rn.find("\r", pos)) != std::string::npos) { + line_rn.erase(pos, 1); + } + // remove '\n' since we add it back in below + pos = 0; + while ((pos = line_rn.find("\n", pos)) != std::string::npos) { + line_rn.erase(pos, 1); + } + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, line); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, line_rn + '\n'); return result; } @@ -149,12 +162,11 @@ namespace detail { // loop through extensible groups and add ProgramLine to vector result. auto groups = extensibleGroups(); - unsigned i = 0; + for (auto group = groups.begin(); group != groups.end(); ++group) { const auto & line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); OS_ASSERT(line); - result[i] += line.get(); - i++; + result.push_back(line.get()); } return result; } @@ -172,16 +184,11 @@ namespace detail { //clobber existing body this->eraseBody(); - // remove '\r' from the body string - //for (int i = 0; i < lines.size(); i++) { - // temp = lines[i]; - // lines[i] = temp.erase(std::remove(lines[i].begin(), lines[i].end(), '\r'), lines[i].end()); - //} //add program lines to body std::vector ok(lines.size(), false); for (int i = 0; i < lines.size(); i++) { - WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, lines[i]); + //use method addLine to add each line + result = addLine(lines[i]); ok.push_back(result); } //check if all the programs set true diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index f7053518edf..e4c73d749d0 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -74,11 +74,76 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) //add program EnergyManagementSystemProgram fan_program_1(model); - std::string programName = fan.name().get() + "Pressure Rise Program by Line"; + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); + //this body has /r/n in it std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body fan_program_1.setBody(fan_program_1_body); - fan_program_1.lines().get(); - EXPECT_EQ(2, fan_program_1.lines().get().size()); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + boost::optional> lines = fan_program_1.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + //TODO + //EXPECT_EQ(2, fan_program_1.referencedObjects.size()) + //EXPECT_EQ(0, fan_program_1.invalidReferencedObjects.size()) + //fan_actuator.remove + //EXPECT_EQ(1, fan_program_1.invalidReferencedObjects.size()) + + // Create a third program from a vector of lines + EnergyManagementSystemProgram fan_program_2(model); + programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_2.setName(programName); + //create program by individual lines + std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + + fan_program_2.addLine(line1); + fan_program_2.addLine(line2); + + //check body + body = fan_program_2.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_2.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + + // # Create a third program from vector of lines + EnergyManagementSystemProgram fan_program_3(model); + programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; + fan_program_3.setName(programName); + + std::vector vectorOfLines; + vectorOfLines.push_back(line1); + vectorOfLines.push_back(line2); + fan_program_3.setLines(vectorOfLines); + + //check body + body = fan_program_3.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + } From 12f5c869a3030be8d103b76814927bc13ff200ed Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 21:10:55 -0600 Subject: [PATCH 049/159] referencedObjects method works --- .../model/EnergyManagementSystemProgram.cpp | 49 +++++++++++-------- .../EnergyManagementSystemProgram_GTest.cpp | 7 ++- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 94f76d4b4b6..da9bcc75991 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -26,9 +26,12 @@ #include "../utilities/core/Assert.hpp" #include "ModelExtensibleGroup.hpp" +#include "Model.hpp" #include "../utilities/core/String.hpp" #include "../utilities/core/StringHelpers.hpp" +#include "../utilities/core/UUID.hpp" +//#include "../utilities/idf/Handle.hpp" #include @@ -202,28 +205,34 @@ namespace detail { } boost::optional> EnergyManagementSystemProgram_Impl::referencedObjects() const { - //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); - //TODO return vector of model objects that are referenced in program + //return vector of model objects that are referenced in program std::vector result; - std::vector body; - //test vector - std::string test; - test = "blah"; - body.push_back(test); - test = "set temp = 92093437-80c7-47e2-82bf-015241c60012"; - body.push_back(test); - test = "blah"; - body.push_back(test); - - //assume body is a vector of strings - for (int i = 0; i < body.size(); i++) { - //split string on whitespaces to isolate possible uids - std::vector results = splitString(body[i], ' '); - for (int j = 0; j < results.size(); j++) { - if (results[j].size() == 36) { - std::string possible_uid = results[j]; - //look to see if uid is in the model and return the object + boost::optional> body = this->lines(); + if (body.is_initialized()) { + //assume body is a vector of strings + for (int i = 0; i < body.get().size(); i++) { + //split string on whitespaces to isolate possible uids + std::vector results = splitString(body.get()[i], ' '); + for (int j = 0; j < results.size(); j++) { + if (results[j].size() == 38) { + //remove {} from uid string + std::string possible_uid = results[j].substr(1, results[j].size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //std::vector handle = &uid; + Model m = this->model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (int k = 0; k < modelObjects.size(); k++) { + if (modelObjects[k].handle() == uid) { + result.push_back(modelObjects[k]); + }; + } + }; + } } } } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index e4c73d749d0..9d495844e1e 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -39,6 +39,7 @@ #include "../../utilities/data/TimeSeries.hpp" #include "../../utilities/core/Compare.hpp" #include "../../utilities/core/Optional.hpp" +#include "../../utilities/core/UUID.hpp" using namespace openstudio; using namespace openstudio::model; @@ -96,9 +97,11 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(2, lines.get().size()); EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); - + + EXPECT_EQ(2, fan_program_1.referencedObjects().get().size()); + EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[0].nameString() == fanName) || (fan_program_1.referencedObjects().get()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[1].nameString() == fanName) || (fan_program_1.referencedObjects().get()[1].nameString() == "OATdb Sensor")); //TODO - //EXPECT_EQ(2, fan_program_1.referencedObjects.size()) //EXPECT_EQ(0, fan_program_1.invalidReferencedObjects.size()) //fan_actuator.remove //EXPECT_EQ(1, fan_program_1.invalidReferencedObjects.size()) From fe7446a145b5f422e300bed3f05cbcff19665b2a Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 17 Aug 2016 22:11:21 -0600 Subject: [PATCH 050/159] invalidReferencedObjects method works added invalidReferencedObjects and ReferencedObjects tests --- .../model/EnergyManagementSystemProgram.cpp | 43 +++++++++++++-- .../model/EnergyManagementSystemProgram.hpp | 2 +- .../EnergyManagementSystemProgram_Impl.hpp | 2 +- .../EnergyManagementSystemProgram_GTest.cpp | 53 ++++++++++++++++--- 4 files changed, 87 insertions(+), 13 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index da9bcc75991..19410b77297 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -239,10 +239,45 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { - //return getString(OS_EnergyManagementSystem_ProgramFields::EnergyPlusModelCallingPoint, true); + boost::optional> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { //TODO return vector of body lines that contain missing uid strings for invalid referenced objects - std::vector result; + std::vector result; + + boost::optional> body = this->lines(); + if (body.is_initialized()) { + //assume body is a vector of strings + for (int i = 0; i < body.get().size(); i++) { + int found = 0; + //split string on whitespaces to isolate possible uids + std::vector results = splitString(body.get()[i], ' '); + for (int j = 0; j < results.size(); j++) { + if (results[j].size() == 38) { + //possible uid so set found to 1 + found = 1; + //remove {} from uid string + std::string possible_uid = results[j].substr(1, results[j].size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //std::vector handle = &uid; + Model m = this->model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (int k = 0; k < modelObjects.size(); k++) { + if (modelObjects[k].handle() == uid) { + found++; + }; + } + }; + } + } + //possible uid not found in model + if (found == 1) { + result.push_back(body.get()[i]); + }; + } + } return result; } @@ -288,7 +323,7 @@ boost::optional> EnergyManagementSystemProgram::referen return getImpl()->referencedObjects(); } -boost::optional> EnergyManagementSystemProgram::invalidReferencedObjects() const { +boost::optional> EnergyManagementSystemProgram::invalidReferencedObjects() const { return getImpl()->invalidReferencedObjects(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 402d261e7e6..60b12dcd224 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -57,7 +57,7 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { boost::optional> referencedObjects() const; - boost::optional> invalidReferencedObjects() const; + boost::optional> invalidReferencedObjects() const; //@} /** @name Setters */ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index e1cec0ee7cd..8a627e71c10 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -68,7 +68,7 @@ namespace detail { boost::optional> referencedObjects() const; - boost::optional> invalidReferencedObjects() const; + boost::optional> invalidReferencedObjects() const; //@} diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 9d495844e1e..d6f5dcc0cd2 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -101,22 +101,34 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(2, fan_program_1.referencedObjects().get().size()); EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[0].nameString() == fanName) || (fan_program_1.referencedObjects().get()[0].nameString() == "OATdb Sensor")); EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[1].nameString() == fanName) || (fan_program_1.referencedObjects().get()[1].nameString() == "OATdb Sensor")); - //TODO - //EXPECT_EQ(0, fan_program_1.invalidReferencedObjects.size()) - //fan_actuator.remove - //EXPECT_EQ(1, fan_program_1.invalidReferencedObjects.size()) - - // Create a third program from a vector of lines + EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().get().size()); + fanActuator.remove(); + EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().get().size()); + + //add actuator on fan again + EnergyManagementSystemActuator fanActuator2(fan); + fanName = fan.name().get() + "Press Actuator"; + fanActuator2.setName(fanName); + fanControlType = "Fan Pressure Rise"; + fanActuator2.setActuatedComponentControlType(fanControlType); + + // Create a second program from a vector of lines EnergyManagementSystemProgram fan_program_2(model); programName = fan.name().get() + "Pressure Rise Program by Line"; fan_program_2.setName(programName); //create program by individual lines std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; - std::string line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; fan_program_2.addLine(line1); fan_program_2.addLine(line2); + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //check body body = fan_program_2.body(); EXPECT_EQ(fan_program_body_test, body.get()); @@ -127,6 +139,17 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); + EXPECT_EQ(2, fan_program_2.referencedObjects().get().size()); + EXPECT_EQ(true, (fan_program_2.referencedObjects().get()[0].nameString() == fanName) || (fan_program_2.referencedObjects().get()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects().get()[1].nameString() == fanName) || (fan_program_2.referencedObjects().get()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().get().size()); + OATdbSensor.remove(); + EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().get().size()); + + //add sensor back in + EnergyManagementSystemSensor OATdbSensor2(model); + OATdbSensor2.setName("OATdb Sensor"); + OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); // # Create a third program from vector of lines EnergyManagementSystemProgram fan_program_3(model); @@ -134,10 +157,18 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) fan_program_3.setName(programName); std::vector vectorOfLines; + line1 = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\r\n"; + line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; vectorOfLines.push_back(line1); vectorOfLines.push_back(line2); fan_program_3.setLines(vectorOfLines); + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //check body body = fan_program_3.body(); EXPECT_EQ(fan_program_body_test, body.get()); @@ -148,5 +179,13 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); + EXPECT_EQ(2, fan_program_3.referencedObjects().get().size()); + EXPECT_EQ(true, (fan_program_3.referencedObjects().get()[0].nameString() == fanName) || (fan_program_3.referencedObjects().get()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects().get()[1].nameString() == fanName) || (fan_program_3.referencedObjects().get()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().get().size()); + OATdbSensor2.remove(); + EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().get().size()); + fanActuator2.remove(); + EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().get().size()); } From 13ba396f560db8c8f7bf6c2d874964628194d610 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 18 Aug 2016 11:02:18 -0600 Subject: [PATCH 051/159] cleanup --- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 6 +----- openstudiocore/src/model/EnergyManagementSystemProgram.hpp | 4 ---- .../model/EnergyManagementSystemProgramCallingManager.cpp | 2 -- .../model/EnergyManagementSystemProgramCallingManager.hpp | 5 ----- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 4 ---- .../src/model/EnergyManagementSystemProgram_Impl.hpp | 4 ---- openstudiocore/src/model/EnergyManagementSystemSensor.cpp | 6 ------ .../src/model/EnergyManagementSystemSensor_Impl.hpp | 1 - 8 files changed, 1 insertion(+), 31 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 19410b77297..95290c2119c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -33,8 +33,6 @@ #include "../utilities/core/UUID.hpp" //#include "../utilities/idf/Handle.hpp" -#include - namespace openstudio { namespace model { @@ -240,7 +238,7 @@ namespace detail { } boost::optional> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { - //TODO return vector of body lines that contain missing uid strings for invalid referenced objects + //return vector of body lines that contain missing uid strings for invalid referenced objects std::vector result; boost::optional> body = this->lines(); @@ -287,8 +285,6 @@ EnergyManagementSystemProgram::EnergyManagementSystemProgram(const Model& model) : ModelObject(EnergyManagementSystemProgram::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. } IddObjectType EnergyManagementSystemProgram::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 60b12dcd224..cc8e81543bb 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -49,8 +49,6 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. - boost::optional body() const; boost::optional> lines() const; @@ -63,8 +61,6 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. - bool setBody(std::string& body); bool eraseBody(); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 42c16613721..4c5745aca02 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -212,8 +212,6 @@ EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallin : ModelObject(EnergyManagementSystemProgramCallingManager::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. } IddObjectType EnergyManagementSystemProgramCallingManager::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 376ed497790..233942d23d2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -60,8 +60,6 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject std::vector nullPrograms() const; - // TODO: Handle this object's extensible fields. - //@} /** @name Setters */ //@{ @@ -82,9 +80,6 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool removeNullPrograms(); - - // TODO: Handle this object's extensible fields. - //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 8a80b5683c4..164d4c5583a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -69,8 +69,6 @@ namespace detail { std::vector nullPrograms() const; - // TODO: Handle this object's extensible fields. - //@} /** @name Setters */ //@{ @@ -91,8 +89,6 @@ namespace detail { bool removeNullPrograms(); - // TODO: Handle this object's extensible fields. - //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index 8a627e71c10..b1d8ffefdcb 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -60,8 +60,6 @@ namespace detail { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. - boost::optional body() const; boost::optional> lines() const; @@ -75,8 +73,6 @@ namespace detail { /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. - bool setBody(std::string& body); bool eraseBody(); diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index abb502ae8e4..d47e88f39e9 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -20,7 +20,6 @@ #include "EnergyManagementSystemSensor.hpp" #include "EnergyManagementSystemSensor_Impl.hpp" -// TODO: Check the following class names against object getters and setters. #include "OutputVariable.hpp" #include "OutputVariable_Impl.hpp" #include "OutputMeter.hpp" @@ -120,11 +119,6 @@ EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model) : ModelObject(EnergyManagementSystemSensor::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName - bool ok = true; - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemSensor::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index ab92210caaa..d2352d20f71 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -30,7 +30,6 @@ namespace openstudio { namespace model { -// TODO: Check the following class names against object getters and setters. class OutputVariable; class OutputMeter; From ea8e4d4315d00a3f98ceee624a8e5129ada45fa8 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 18 Aug 2016 14:16:53 -0600 Subject: [PATCH 052/159] add tests for all methods in sensor, actuator and program bug fix --- .../EnergyManagementSystemActuator_GTest.cpp | 4 ++++ .../test/EnergyManagementSystemProgram_GTest.cpp | 11 +++++++++++ .../test/EnergyManagementSystemSensor_GTest.cpp | 16 ++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index 6312a2ba9e8..852a81ede87 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -54,6 +54,7 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) // add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); + FanConstantVolume fan2(model, s); // add actuator EnergyManagementSystemActuator fanActuator(fan); @@ -64,5 +65,8 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) EXPECT_EQ(fan, fanActuator.actuatedComponent()); EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); + fanActuator.setActuatedComponent(fan2); + EXPECT_EQ(fan2, fanActuator.actuatedComponent()); + } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index d6f5dcc0cd2..ef1ea0ab795 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -187,5 +187,16 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().get().size()); fanActuator2.remove(); EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().get().size()); + + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + fan_program_3.addLine(line1); + lines = fan_program_3.lines(); + EXPECT_EQ(3, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[2]); + fan_program_3.eraseBody(); + body = fan_program_3.body(); + EXPECT_EQ("", body.get()); + } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 7d0b6e91d86..0719f396a98 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -61,5 +61,21 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("OATdb Sensor", OATdbSensor.nameString()); EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle() ); EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); + EXPECT_EQ("", OATdbSensor.keyName().get()); + + // add Zone Lights Electric Power to both zones + OutputVariable lightsElectricPower("Zone Lights Electric Power", model); + EXPECT_EQ("*", lightsElectricPower.keyValue()); + EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); + + // add light sensor on zone1 + EnergyManagementSystemSensor lights(model); + lights.setName("Light Sensor"); + lights.setOutputVariable(lightsElectricPower); + lights.setKeyName(zone1.name().get()); + + EXPECT_EQ(zone1.name().get(), lights.keyName().get()); + EXPECT_EQ("Light Sensor", lights.nameString()); + } From 54ce6e54249b689b414ebde9704b746c0025feb3 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 18 Aug 2016 19:00:35 -0600 Subject: [PATCH 053/159] change return type for swiq add EMS to ForwardTranslator --- .../src/energyplus/ForwardTranslator.cpp | 5 +++ .../src/energyplus/ForwardTranslator.hpp | 12 +++++++ .../model/EnergyManagementSystemProgram.cpp | 12 +++---- .../model/EnergyManagementSystemProgram.hpp | 6 ++-- .../EnergyManagementSystemProgram_Impl.hpp | 6 ++-- .../EnergyManagementSystemProgram_GTest.cpp | 32 +++++++++---------- 6 files changed, 45 insertions(+), 28 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 1cee3b294d6..43dfe18595a 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -2930,6 +2930,11 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_Meter_CustomDecrement); result.push_back(IddObjectType::OS_Output_Variable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_Actuator); + result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); + result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); + result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); + return result; } diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 3e6cb475a09..8610d8a21e7 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -143,6 +143,10 @@ class ElectricLoadCenterDistribution; class ElectricLoadCenterInverterLookUpTable; class ElectricLoadCenterInverterSimple; class ElectricLoadCenterStorageSimple; +class EnergyManagementSystemActuator; +class EnergyManagementSystemProgram; +class EnergyManagementSystemProgramCallingManager; +class EnergyManagementSystemSensor; class EvaporativeCoolerDirectResearchSpecial; class EvaporativeCoolerIndirectResearchSpecial; class EvaporativeFluidCoolerSingleSpeed; @@ -640,6 +644,14 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateElectricLoadCenterStorageSimple( model::ElectricLoadCenterStorageSimple & modelObject ); + boost::optional translateEnergyManagementSystemActuator(model::EnergyManagementSystemActuator & modelObejct); + + boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObejct); + + boost::optional translateEnergyManagementSystemProgramCallingManager(model::EnergyManagementSystemProgramCallingManager & modelObejct); + + boost::optional translateEnergyManagementSystemSensor(model::EnergyManagementSystemSensor & modelObejct ); + boost::optional translateEvaporativeFluidCoolerSingleSpeed( model::EvaporativeFluidCoolerSingleSpeed & modelObject ); boost::optional translateEvaporativeFluidCoolerTwoSpeed( model::EvaporativeFluidCoolerTwoSpeed & modelObject ); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 95290c2119c..6a9a059360f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -86,7 +86,7 @@ namespace detail { return body; } - bool EnergyManagementSystemProgram_Impl::setBody(std::string& body) { + bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { //set body of program to input string bool result = false; //if body string empty then return false @@ -202,7 +202,7 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgram_Impl::referencedObjects() const { + std::vector EnergyManagementSystemProgram_Impl::referencedObjects() const { //return vector of model objects that are referenced in program std::vector result; @@ -237,7 +237,7 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { + std::vector EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { //return vector of body lines that contain missing uid strings for invalid referenced objects std::vector result; @@ -295,7 +295,7 @@ boost::optional EnergyManagementSystemProgram::body() const { return getImpl()->body(); } -bool EnergyManagementSystemProgram::setBody(std::string& body) { +bool EnergyManagementSystemProgram::setBody(const std::string& body) { return getImpl()->setBody(body); } @@ -315,11 +315,11 @@ bool EnergyManagementSystemProgram::setLines(const std::vector& lin return getImpl()->setLines(lines); } -boost::optional> EnergyManagementSystemProgram::referencedObjects() const { +std::vector EnergyManagementSystemProgram::referencedObjects() const { return getImpl()->referencedObjects(); } -boost::optional> EnergyManagementSystemProgram::invalidReferencedObjects() const { +std::vector EnergyManagementSystemProgram::invalidReferencedObjects() const { return getImpl()->invalidReferencedObjects(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index cc8e81543bb..95d1e031e66 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -53,15 +53,15 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { boost::optional> lines() const; - boost::optional> referencedObjects() const; + std::vector referencedObjects() const; - boost::optional> invalidReferencedObjects() const; + std::vector invalidReferencedObjects() const; //@} /** @name Setters */ //@{ - bool setBody(std::string& body); + bool setBody(const std::string& body); bool eraseBody(); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index b1d8ffefdcb..1fa6e24585b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -64,16 +64,16 @@ namespace detail { boost::optional> lines() const; - boost::optional> referencedObjects() const; + std::vector referencedObjects() const; - boost::optional> invalidReferencedObjects() const; + std::vector invalidReferencedObjects() const; //@} /** @name Setters */ //@{ - bool setBody(std::string& body); + bool setBody(const std::string& body); bool eraseBody(); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index ef1ea0ab795..d5e6583211a 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -98,12 +98,12 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); - EXPECT_EQ(2, fan_program_1.referencedObjects().get().size()); - EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[0].nameString() == fanName) || (fan_program_1.referencedObjects().get()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_1.referencedObjects().get()[1].nameString() == fanName) || (fan_program_1.referencedObjects().get()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().get().size()); + EXPECT_EQ(2, fan_program_1.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); fanActuator.remove(); - EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().get().size()); + EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); //add actuator on fan again EnergyManagementSystemActuator fanActuator2(fan); @@ -139,12 +139,12 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); - EXPECT_EQ(2, fan_program_2.referencedObjects().get().size()); - EXPECT_EQ(true, (fan_program_2.referencedObjects().get()[0].nameString() == fanName) || (fan_program_2.referencedObjects().get()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_2.referencedObjects().get()[1].nameString() == fanName) || (fan_program_2.referencedObjects().get()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().get().size()); + EXPECT_EQ(2, fan_program_2.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); OATdbSensor.remove(); - EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().get().size()); + EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); //add sensor back in EnergyManagementSystemSensor OATdbSensor2(model); @@ -179,14 +179,14 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); - EXPECT_EQ(2, fan_program_3.referencedObjects().get().size()); - EXPECT_EQ(true, (fan_program_3.referencedObjects().get()[0].nameString() == fanName) || (fan_program_3.referencedObjects().get()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_3.referencedObjects().get()[1].nameString() == fanName) || (fan_program_3.referencedObjects().get()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().get().size()); + EXPECT_EQ(2, fan_program_3.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); OATdbSensor2.remove(); - EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().get().size()); + EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); fanActuator2.remove(); - EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().get().size()); + EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().size()); lines = fan_program_3.lines(); EXPECT_EQ(2, lines.get().size()); From 4dfc17f1fb2485cb1a4973a6f68bcb185240b528 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sun, 21 Aug 2016 09:20:27 -0600 Subject: [PATCH 054/159] passes ruby test. --- .../ruby/openstudio/model/test/Ems_Test.rb | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 openstudiocore/ruby/openstudio/model/test/Ems_Test.rb diff --git a/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb new file mode 100644 index 00000000000..99ab08f0fbf --- /dev/null +++ b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb @@ -0,0 +1,117 @@ + +#require 'openstudio' +require "C:/Projects/OpenStudio/build/OSCore-prefix/src/OSCore-build/ruby/Debug/openstudio" + +#require 'test/unit' +require 'minitest/autorun' + + #load a model into OS & version translates, exiting and erroring if a problem is found + def safe_load_model(model_path_string) + model_path = OpenStudio::Path.new(model_path_string) + if OpenStudio::exists(model_path) + versionTranslator = OpenStudio::OSVersion::VersionTranslator.new + model = versionTranslator.loadModel(model_path) + if model.empty? + puts "Version translation failed for #{model_path_string}" + exit + else + model = model.get + end + else + puts "#{model_path_string} couldn't be found" + exit + end + return model + end + +#class TestEms < Test::Unit::TestCase +#class TestEms < MiniTest::Unit::TestCase +class TestEms < MiniTest::Test + + def test_ems + model = safe_load_model("#{Dir.pwd}/example.osm") + + ### Sensor ### + + # Create an output variable for OATdb + output_var = "Site Outdoor Air Drybulb Temperature" + output_var_oat = OpenStudio::Model::OutputVariable.new(output_var, model) + + # Create a sensor to sense the outdoor air temperature + oat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model) + oat_sensor_name = "OATdb Sensor" + oat_sensor.setName(oat_sensor_name) + oat_sensor.setOutputVariable(output_var_oat) + + # Assertions for sensor setters and getters + assert_equal oat_sensor_name, oat_sensor.name.get.to_s + assert_equal output_var, oat_sensor.outputVariable.get.variableName + + ### Actuator ### + + # Get the first fan from the example model + fan = model.getFanConstantVolumes[0] + + # Create an actuator to set the fan pressure rise + fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan) + fan_actuator.setName("#{fan.name} Press Actuator") + fan_press = "Fan Pressure Rise" + fan_actuator.setActuatedComponentControlType(fan_press) + fan_actuator.setActuatedComponent(fan) + + # Assertions for actuator setters and getters + assert_equal(fan, fan_actuator.actuatedComponent) + assert_equal(fan_press, fan_actuator.actuatedComponentControlType) + + ### Program ### + + # Create a program all at once + fan_program_1 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) + fan_program_1.setName("#{fan.name} Pressure Rise Program by Line") + fan_program_1_body = <<-EMS + SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense + SET #{fan_actuator.handle} = 250 * mult !- More nonsense + EMS + fan_program_1.setBody(fan_program_1_body) + + # Assertion for the number of lines + assert_equal(2, fan_program_1.lines.get.size) + # Assertion for the objects that are referenced + assert_equal(2, fan_program_1.referencedObjects.size) + # Assertion for the number of invalid objects + assert_equal(0, fan_program_1.invalidReferencedObjects.size) + # Delete the actuator + fan_actuator.remove + # Assertion for the new number of invalid objects + assert_equal(1, fan_program_1.invalidReferencedObjects.size) + + # Create a third program from a vector of lines + fan_program_2 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) + fan_program_2.setName("#{fan.name} Pressure Rise Program by Line") + fan_program_2.addLine("SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense") + fan_program_2.addLine("SET #{fan_actuator.handle} = 250 * mult !- More nonsense") + + # Assertion for the number of lines + assert_equal(2, fan_program_2.lines.get.size) + # Assertion for the objects that are referenced + assert_equal(1, fan_program_2.referencedObjects.size) + # Assertion for the new number of invalid objects + assert_equal(1, fan_program_2.invalidReferencedObjects.size) + + # Create a third program from vector of lines + fan_program_3 = OpenStudio::Model::EnergyManagementSystemProgram.new(model) + fan_program_3.setName("#{fan.name} Pressure Rise Program by Vector of Lines") + fan_program_3_lines = [] + fan_program_3_lines << "SET mult = #{oat_sensor.handle} / 15.0 !- This is nonsense" + fan_program_3_lines << "SET #{fan_actuator.handle} = 250 * mult !- More nonsense" + fan_program_3.setLines(fan_program_3_lines) + + # Assertion for the number of lines + assert_equal(2, fan_program_3.lines.get.size) + # Assertion for the objects that are referenced + assert_equal(1, fan_program_3.referencedObjects.size) + # Assertion for the new number of invalid objects + assert_equal(1, fan_program_3.invalidReferencedObjects.size) + end + +end From 4c0e45fcc644df9216cef325006a261c588bdcb9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sun, 21 Aug 2016 11:28:48 -0600 Subject: [PATCH 055/159] ems ruby test update --- openstudiocore/ruby/openstudio/model/test/Ems_Test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb index 99ab08f0fbf..2780097ffed 100644 --- a/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb +++ b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb @@ -29,8 +29,8 @@ def safe_load_model(model_path_string) class TestEms < MiniTest::Test def test_ems - model = safe_load_model("#{Dir.pwd}/example.osm") - + #model = safe_load_model("#{Dir.pwd}/example.osm") + model = OpenStudio::Model::Model.new ### Sensor ### # Create an output variable for OATdb @@ -50,7 +50,9 @@ def test_ems ### Actuator ### # Get the first fan from the example model - fan = model.getFanConstantVolumes[0] + #fan = model.getFanConstantVolumes[0] + always_on = model.alwaysOnDiscreteSchedule + fan = OpenStudio::Model::FanConstantVolume.new(model,always_on) # Create an actuator to set the fan pressure rise fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fan) From 13d7fdee40c6ec0f656d163180316672fb5bb842 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sun, 21 Aug 2016 17:26:43 -0600 Subject: [PATCH 056/159] programCallingManager g_test and debuging --- .../model/EnergyManagementSystemProgramCallingManager.cpp | 6 +++--- .../model/EnergyManagementSystemProgramCallingManager.hpp | 2 +- .../EnergyManagementSystemProgramCallingManager_Impl.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 4c5745aca02..4a01200ad10 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -153,13 +153,13 @@ namespace detail { IdfExtensibleGroup idfGroup = insertExtensibleGroup(index, StringVector()); OS_ASSERT(!idfGroup.empty()); ModelExtensibleGroup group = idfGroup.cast(); - bool result = group.setPointer(0, program.handle()); + result = group.setPointer(0, program.handle()); OS_ASSERT(result); } return result; } - bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { + bool EnergyManagementSystemProgramCallingManager_Impl::setPrograms(const std::vector& programs) { //add programs to end of vector of programs std::vector ok(programs.size(), false); bool result = false; @@ -259,7 +259,7 @@ bool EnergyManagementSystemProgramCallingManager::setProgram(const EnergyManagem return getImpl()->setProgram(program, index); } -bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector& programs) { +bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector& programs) { return getImpl()->setPrograms(programs); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 233942d23d2..924f833ca89 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -76,7 +76,7 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); - bool setPrograms(const std::vector& programs); + bool setPrograms(const std::vector& programs); bool removeNullPrograms(); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 164d4c5583a..b37b5f4f53b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -85,7 +85,7 @@ namespace detail { bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); - bool setPrograms(const std::vector& programs); + bool setPrograms(const std::vector& programs); bool removeNullPrograms(); From c790eb12c74990ed900faad8d39b6e75a366da7e Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 09:00:10 -0600 Subject: [PATCH 057/159] add test/EnergyManagementSystemProgramCallingManager_GTest.cpp to repo and CMakeLists.txt --- openstudiocore/src/model/CMakeLists.txt | 2 + ...ementSystemProgramCallingManager_GTest.cpp | 237 ++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 5c324d5e4bf..681d8dd7ceb 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1613,6 +1613,8 @@ set(${target_name}_test_src test/ElectricLoadCenterInverterLookUpTable_GTest.cpp test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp + test/EnergyManagementSystemProgram_GTest.cpp + test/EnergyManagementSystemProgramCallingManager_GTest.cpp test/EnergyManagementSystemSensor_GTest.cpp test/EvaporativeCoolerDirectResearchSpecial_GTest.cpp test/EvaporativeCoolerIndirectResearchSpecial_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp new file mode 100644 index 00000000000..e9a051e411c --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp @@ -0,0 +1,237 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../FanConstantVolume.hpp" +#include "../FanConstantVolume_Impl.hpp" +#include "../Schedule.hpp" +#include "../EnergyManagementSystemActuator.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemProgram.hpp" +#include "../EnergyManagementSystemProgramCallingManager.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" +#include "../../utilities/core/UUID.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + + //add program + EnergyManagementSystemProgram fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + // Create a second program from a vector of lines + EnergyManagementSystemProgram fan_program_2(model); + programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_2.setName(programName); + //create program by individual lines + std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + + fan_program_2.addLine(line1); + fan_program_2.addLine(line2); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_2.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + // # Create a third program from vector of lines + EnergyManagementSystemProgram fan_program_3(model); + programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; + fan_program_3.setName(programName); + + std::vector vectorOfLines; + line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + vectorOfLines.push_back(line1); + vectorOfLines.push_back(line2); + fan_program_3.setLines(vectorOfLines); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_3.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //start program calling manager testing + EnergyManagementSystemProgramCallingManager fan_pcm(model); + fan_pcm.setName("Best Program Calling Manager"); + //get calling points + std::vector calling_points = fan_pcm.validCallingPointValues(); + + //check if BeginNewEnviornment is in callingpoints. + bool finds = (std::find(calling_points.begin(), calling_points.end(), "BeginNewEnvironment") != calling_points.end()); + EXPECT_EQ(true, finds); + + bool callpt = fan_pcm.setCallingPoint("BeginNewEnvironment"); + EXPECT_EQ(true, callpt); + EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint().get()); + + //should start with 0 programs + std::vector programs = fan_pcm.programs(); + EXPECT_EQ(0,programs.size()); + //should not be initialized yet + boost::optional program = fan_pcm.getProgram(1); + EXPECT_EQ(false, program.is_initialized()); + + bool add_result = fan_pcm.addProgram(fan_program_1); + EXPECT_EQ(true, add_result); + add_result = fan_pcm.addProgram(fan_program_2); + EXPECT_EQ(true, add_result); + EXPECT_EQ(2, fan_pcm.programs().size()); + EXPECT_EQ(fan_program_2.nameString(), fan_pcm.programs()[1].nameString()); + //set program one slot too big, will return false + bool insert_result = fan_pcm.setProgram(fan_program_3, 3); + EXPECT_EQ(false, insert_result); + //still only 2 programs + EXPECT_EQ(2, fan_pcm.programs().size()); + //set program in last slot + insert_result = fan_pcm.setProgram(fan_program_3, 2); + EXPECT_EQ(true, insert_result); + //3 programs + EXPECT_EQ(3, fan_pcm.programs().size()); + //check program name + program = fan_pcm.getProgram(0); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_1.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(),program.get().nameString()); + //check program name + program = fan_pcm.getProgram(2); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); + //set program 3 in program 2 slot moving the rest down + insert_result = fan_pcm.setProgram(fan_program_3, 1); + EXPECT_EQ(true, insert_result); + //now 4 programs + EXPECT_EQ(4, fan_pcm.programs().size()); + //check program name is now program 3's + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); + //erase program 3 in 2nd slot + bool erase_prog = fan_pcm.eraseProgram(1); + EXPECT_EQ(true, erase_prog); + //check for null programs + std::vector nullProgs = fan_pcm.nullPrograms(); + //should not be any if erasePrograms reindexed correctly + EXPECT_EQ(0, nullProgs.size()); + //check program name is back to program 2's + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); + + //erase all programs + fan_pcm.erasePrograms(); + //now 0 programs + EXPECT_EQ(0, fan_pcm.programs().size()); + + //create vector of programs + std::vector new_programs; + new_programs.push_back(fan_program_1); + new_programs.push_back(fan_program_2); + new_programs.push_back(fan_program_3); + //set vector of programs + insert_result = fan_pcm.setPrograms(new_programs); + //3 programs + EXPECT_EQ(3, fan_pcm.programs().size()); + //check program name + program = fan_pcm.getProgram(0); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_1.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(2); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); +} + From 851a43ec6484d2779c45f6e320a932615efd4101 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 10:45:16 -0600 Subject: [PATCH 058/159] add sensor to ForwardTranslator.cpp --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + openstudiocore/src/energyplus/ForwardTranslator.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index ad6a07684e4..2065bff937c 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -119,6 +119,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterInverterLookUpTable.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterInverterSimple.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeFluidCoolerSingleSpeed.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 43dfe18595a..2be2ae13350 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1323,6 +1323,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateElectricLoadCenterStorageSimple(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor: + { + model::EnergyManagementSystemSensor temp = modelObject.cast(); + retVal = translateEnergyManagementSystemSensor(temp); + break; + } case openstudio::IddObjectType::OS_EvaporativeCooler_Direct_ResearchSpecial : { model::EvaporativeCoolerDirectResearchSpecial evap = modelObject.cast(); From 7fab081bfcd6e343a433ad6d00cb347bd1879a71 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 10:46:07 -0600 Subject: [PATCH 059/159] add ForwardTranslateEnergyManagementSystemSensor.cpp --- ...dTranslateEnergyManagementSystemSensor.cpp | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp new file mode 100644 index 00000000000..18ae214c018 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp @@ -0,0 +1,77 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemSensor.hpp" +#include "../../model/EnergyManagementSystemSensor_Impl.hpp" + + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemSensor(EnergyManagementSystemSensor & modelObject) +{ + boost::optional d; + boost::optional m; + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Sensor); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + s = modelObject.keyName(); + if (s) { + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, s.get()); + } + d = modelObject.outputVariable(); + if (d) { + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, d.get().nameString()); + } + m = modelObject.outputMeter(); + if (m){ + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, m.get().nameString()); + } + + return idfObject; +} + +} // energyplus + +} // openstudio + From 8442d00415112e9bda0839ade81971ceae9df267 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 11:13:28 -0600 Subject: [PATCH 060/159] add actuator to ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 6 ++ ...ranslateEnergyManagementSystemActuator.cpp | 69 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 2065bff937c..4d3519e12b9 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -119,6 +119,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterInverterLookUpTable.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterInverterSimple.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 2be2ae13350..60b73de36d5 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1323,6 +1323,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateElectricLoadCenterStorageSimple(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator: + { + model::EnergyManagementSystemActuator temp = modelObject.cast(); + retVal = translateEnergyManagementSystemActuator(temp); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor: { model::EnergyManagementSystemSensor temp = modelObject.cast(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp new file mode 100644 index 00000000000..3f4b9ac002b --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -0,0 +1,69 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemActuator.hpp" +#include "../../model/EnergyManagementSystemActuator_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemActuator(EnergyManagementSystemActuator & modelObject) +{ + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); + + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, "TODO"); + + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); + + + return idfObject; +} + +} // energyplus + +} // openstudio + From 80b7449d11664731d1d7bf7690e98de6182e1aa8 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 13:06:29 -0600 Subject: [PATCH 061/159] forward translator experiment --- .../ForwardTranslateEnergyManagementSystemActuator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index 3f4b9ac002b..043cfd8e3d3 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -54,8 +54,8 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct } idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); - - idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, "TODO"); + //not sure if below will work or not + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.iddObjectType().valueName()); idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); From 3094abeb93f2f54fec5a279018ff943ce88c976a Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 13:36:12 -0600 Subject: [PATCH 062/159] add EMS program to ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 3 +- .../src/energyplus/ForwardTranslator.cpp | 6 ++ ...TranslateEnergyManagementSystemProgram.cpp | 69 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 4d3519e12b9..eb7c183ebe7 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -119,7 +119,8 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterInverterLookUpTable.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterInverterSimple.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp - ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator + ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 60b73de36d5..ecbf516757c 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1329,6 +1329,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemActuator(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_Program: + { + model::EnergyManagementSystemProgram temp = modelObject.cast(); + retVal = EnergyManagementSystemProgram(temp); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor: { model::EnergyManagementSystemSensor temp = modelObject.cast(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp new file mode 100644 index 00000000000..34ae9272ca6 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -0,0 +1,69 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemProgram(EnergyManagementSystemProgram & modelObject) +{ + boost::optional s; + + //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + //m_idfObjects.push_back(idfObject); + IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Program,modelObject); + //Name + s = modelObject.name(); + if (s) { + program.setName(*s); + } + + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + program.pushExtensibleGroup(eg.fields()); + } + return program; +} + +} // energyplus + +} // openstudio + From 46e7bf00a69e2a76af4861dcba8abb4957e23b87 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 13:56:04 -0600 Subject: [PATCH 063/159] add programcallingmanager to ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 6 ++ ...yManagementSystemProgramCallingManager.cpp | 78 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index eb7c183ebe7..965e0605298 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -121,6 +121,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index ecbf516757c..3b842bf5c17 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1335,6 +1335,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = EnergyManagementSystemProgram(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager: + { + model::EnergyManagementSystemProgramCallingManager temp = modelObject.cast(); + retVal = EnergyManagementSystemProgramCallingManager(temp); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor: { model::EnergyManagementSystemSensor temp = modelObject.cast(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp new file mode 100644 index 00000000000..35663ce5192 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp @@ -0,0 +1,78 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" +#include "../../model/EnergyManagementSystemProgramCallingManager.hpp" +#include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemProgramCallingManager(EnergyManagementSystemProgramCallingManager & modelObject) +{ + boost::optional s; + + //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + //m_idfObjects.push_back(idfObject); + IdfObject pcm = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_ProgramCallingManager, modelObject); + //Name + s = modelObject.name(); + if (s) { + pcm.setName(*s); + } + + //callingpoint + s = modelObject.callingPoint(); + if (s) { + pcm.setString(EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, s.get()); + } + + //program names + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + pcm.pushExtensibleGroup(eg.fields()); + } + return pcm; +} + +} // energyplus + +} // openstudio + From 7468ff0cb69f80cdd45bf4deb714d13458b23334 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 16:58:03 -0600 Subject: [PATCH 064/159] switch swig order --- openstudiocore/src/model/ModelCore.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index 4afd805b643..c532f206b69 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -172,8 +172,8 @@ MODELOBJECT_TEMPLATES(GenericModelObject); MODELOBJECT_TEMPLATES(ModelObjectList); MODELOBJECT_TEMPLATES(EnergyManagementSystemSensor); MODELOBJECT_TEMPLATES(EnergyManagementSystemActuator); -MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); +MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); SWIG_MODELOBJECT(ModelObject, 0); SWIG_MODELEXTENSIBLEGROUP(ModelExtensibleGroup); @@ -202,7 +202,7 @@ SWIG_MODELOBJECT(GenericModelObject, 0); SWIG_MODELOBJECT(ModelObjectList, 1); SWIG_MODELOBJECT(EnergyManagementSystemSensor, 1); SWIG_MODELOBJECT(EnergyManagementSystemActuator, 1); -SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); +SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); #endif //MODEL_CORE_I From 26ca9c9b86efb9d7ed8659b5ef2f14b5a48805e3 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 17:58:43 -0600 Subject: [PATCH 065/159] Gtest for EMS ForwardTranslateEnergyManagementSystemSensor.cpp fix optional return in sensor --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + ...dTranslateEnergyManagementSystemSensor.cpp | 4 +- .../src/energyplus/Test/EMS_GTest.cpp | 147 ++++++++++++++++++ .../model/EnergyManagementSystemSensor.cpp | 10 +- 4 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 openstudiocore/src/energyplus/Test/EMS_GTest.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 965e0605298..d67230148f5 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -456,6 +456,7 @@ set(${target_name}_test_src Test/DaylightingDeviceShelf_GTest.cpp Test/DesignSpecificationOutdoorAir_GTest.cpp Test/ElectricEquipment_GTest.cpp + Test/EMS_GTest.cpp Test/ExteriorLights_GTest.cpp Test/GasEquipment_GTest.cpp Test/HotWaterEquipment_GTest.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp index 18ae214c018..57540573aa3 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp @@ -60,11 +60,11 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSen idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, s.get()); } d = modelObject.outputVariable(); - if (d) { + if (d.is_initialized()) { idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, d.get().nameString()); } m = modelObject.outputMeter(); - if (m){ + if (m.is_initialized()){ idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, m.get().nameString()); } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp new file mode 100644 index 00000000000..1f08bbe4602 --- /dev/null +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -0,0 +1,147 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ErrorFile.hpp" +#include "../ForwardTranslator.hpp" +#include "../ReverseTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/Building.hpp" +#include "../../model/Building_Impl.hpp" +#include "../../model/ThermalZone.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemSensor.hpp" +#include "../../model/EnergyManagementSystemSensor_Impl.hpp" + +#include "../../model/Version.hpp" +#include "../../model/Version_Impl.hpp" + +#include "../../utilities/core/Optional.hpp" +#include "../../utilities/core/Checksum.hpp" +#include "../../utilities/core/UUID.hpp" +#include "../../utilities/core/Logger.hpp" +#include "../../utilities/sql/SqlFile.hpp" +#include "../../utilities/idf/IdfFile.hpp" +#include "../../utilities/idf/IdfObject.hpp" + +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#include + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + + +TEST_F(EnergyPlusFixture,ForwardTranslator_EMS) { + //Model model = exampleModel(); + + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); + + // add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + EXPECT_EQ("OATdb Sensor", OATdbSensor.nameString()); + EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle()); + EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); + EXPECT_EQ("", OATdbSensor.keyName().get()); + + // add Zone Lights Electric Power to both zones + OutputVariable lightsElectricPower("Zone Lights Electric Power", model); + EXPECT_EQ("*", lightsElectricPower.keyValue()); + EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); + + // add light sensor on zone1 + EnergyManagementSystemSensor lights(model); + lights.setName("Light Sensor"); + lights.setOutputVariable(lightsElectricPower); + lights.setKeyName(zone1.name().get()); + + EXPECT_EQ(zone1.name().get(), lights.keyName().get()); + EXPECT_EQ("Light Sensor", lights.nameString()); + + + //EXPECT_TRUE(model.getOptionalUniqueModelObject()) << "Example model does not include a Version object."; + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Version).size()); + + model.save(toPath("./EMS_example.osm"), true); + workspace.save(toPath("./EMS_example.idf"), true); +} + +/* +TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateAirLoopHVAC) { + openstudio::model::Model model; + EXPECT_TRUE(model.getOptionalUniqueModelObject()) << "Blank model does not include a Version object."; + + ThermalZone zone1(model); + ThermalZone zone2(model); + ThermalZone zone3(model); + + openstudio::model::AirLoopHVAC airLoopHVAC(model); + airLoopHVAC.addBranchForZone(zone1, boost::none); + airLoopHVAC.addBranchForZone(zone2, boost::none); + airLoopHVAC.addBranchForZone(zone3, boost::none); + + ForwardTranslator trans; + + openstudio::Workspace workspace = trans.translateModel(model); + EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Version).size()); + + ASSERT_NE(unsigned(0),workspace.objects().size()); + + openstudio::path outDir = resourcesPath() / openstudio::toPath("airLoopHVAC.idf"); + boost::filesystem::ofstream ofs(outDir); + workspace.toIdfFile().print(ofs); + ofs.close(); +} +*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index d47e88f39e9..3967ce37211 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -75,16 +75,18 @@ namespace detail { boost::optional EnergyManagementSystemSensor_Impl::outputVariable() const { boost::optional value = optionalOutputVariable(); - if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); + if (!value.is_initialized()) { + LOG(Info, " does not have an Output Variable attached."); + return value; } return value.get(); } boost::optional EnergyManagementSystemSensor_Impl::outputMeter() const { boost::optional value = optionalOutputMeter(); - if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Output Variable or Output Meter attached."); + if (!value.is_initialized()) { + LOG(Info, " does not have an Output Meter attached."); + return value; } return value.get(); } From b8cf6ed1fab798ab4bef3793e24aea92f2112d28 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 22 Aug 2016 18:38:40 -0600 Subject: [PATCH 066/159] add coverage in ForwardTranslator EMS Gtest --- ...ranslateEnergyManagementSystemActuator.cpp | 2 +- .../src/energyplus/Test/EMS_GTest.cpp | 408 +++++++++++++++++- 2 files changed, 389 insertions(+), 21 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index 043cfd8e3d3..7867e558dc7 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -54,7 +54,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct } idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); - //not sure if below will work or not + //TODO below does not work, try switch statement idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.iddObjectType().valueName()); idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 1f08bbe4602..6f519254247 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -28,6 +28,8 @@ #include "../../model/Building.hpp" #include "../../model/Building_Impl.hpp" #include "../../model/ThermalZone.hpp" +#include "../../model/FanConstantVolume.hpp" +#include "../../model/FanConstantVolume_Impl.hpp" #include "../../model/OutputVariable.hpp" #include "../../model/OutputVariable_Impl.hpp" #include "../../model/OutputMeter.hpp" @@ -36,6 +38,12 @@ #include "../../model/Schedule_Impl.hpp" #include "../../model/EnergyManagementSystemSensor.hpp" #include "../../model/EnergyManagementSystemSensor_Impl.hpp" +#include "../../model/EnergyManagementSystemActuator.hpp" +#include "../../model/EnergyManagementSystemActuator_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" +#include "../../model/EnergyManagementSystemProgramCallingManager.hpp" +#include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -68,8 +76,7 @@ using namespace openstudio::model; using namespace openstudio; -TEST_F(EnergyPlusFixture,ForwardTranslator_EMS) { - //Model model = exampleModel(); +TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { Model model; @@ -118,30 +125,391 @@ TEST_F(EnergyPlusFixture,ForwardTranslator_EMS) { workspace.save(toPath("./EMS_example.idf"), true); } -/* -TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateAirLoopHVAC) { - openstudio::model::Model model; - EXPECT_TRUE(model.getOptionalUniqueModelObject()) << "Blank model does not include a Version object."; +TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); ThermalZone zone1(model); ThermalZone zone2(model); - ThermalZone zone3(model); - openstudio::model::AirLoopHVAC airLoopHVAC(model); - airLoopHVAC.addBranchForZone(zone1, boost::none); - airLoopHVAC.addBranchForZone(zone2, boost::none); - airLoopHVAC.addBranchForZone(zone3, boost::none); + // add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + FanConstantVolume fan2(model, s); + + // add actuator + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + EXPECT_EQ(fan, fanActuator.actuatedComponent()); + EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); + + fanActuator.setActuatedComponent(fan2); + EXPECT_EQ(fan2, fanActuator.actuatedComponent()); + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); - ForwardTranslator trans; + model.save(toPath("./EMS_example.osm"), true); + workspace.save(toPath("./EMS_example.idf"), true); +} - openstudio::Workspace workspace = trans.translateModel(model); - EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Version).size()); +TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + + //add program + EnergyManagementSystemProgram fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + boost::optional> lines = fan_program_1.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_1.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); + fanActuator.remove(); + EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); + + //add actuator on fan again + EnergyManagementSystemActuator fanActuator2(fan); + fanName = fan.name().get() + "Press Actuator"; + fanActuator2.setName(fanName); + fanControlType = "Fan Pressure Rise"; + fanActuator2.setActuatedComponentControlType(fanControlType); + + // Create a second program from a vector of lines + EnergyManagementSystemProgram fan_program_2(model); + programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_2.setName(programName); + //create program by individual lines + std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + + fan_program_2.addLine(line1); + fan_program_2.addLine(line2); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_2.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_2.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_2.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); + OATdbSensor.remove(); + EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); + + //add sensor back in + EnergyManagementSystemSensor OATdbSensor2(model); + OATdbSensor2.setName("OATdb Sensor"); + OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + // # Create a third program from vector of lines + EnergyManagementSystemProgram fan_program_3(model); + programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; + fan_program_3.setName(programName); + + std::vector vectorOfLines; + line1 = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\r\n"; + line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + vectorOfLines.push_back(line1); + vectorOfLines.push_back(line2); + fan_program_3.setLines(vectorOfLines); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_3.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_3.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); + OATdbSensor2.remove(); + EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); + fanActuator2.remove(); + EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().size()); + + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + fan_program_3.addLine(line1); + lines = fan_program_3.lines(); + EXPECT_EQ(3, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[2]); + fan_program_3.eraseBody(); + body = fan_program_3.body(); + EXPECT_EQ("", body.get()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); + + model.save(toPath("./EMS_example.osm"), true); + workspace.save(toPath("./EMS_example.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); - ASSERT_NE(unsigned(0),workspace.objects().size()); + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + + //add program + EnergyManagementSystemProgram fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + // Create a second program from a vector of lines + EnergyManagementSystemProgram fan_program_2(model); + programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_2.setName(programName); + //create program by individual lines + std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + + fan_program_2.addLine(line1); + fan_program_2.addLine(line2); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_2.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + // # Create a third program from vector of lines + EnergyManagementSystemProgram fan_program_3(model); + programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; + fan_program_3.setName(programName); + + std::vector vectorOfLines; + line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + line2 = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\r\n"; + vectorOfLines.push_back(line1); + vectorOfLines.push_back(line2); + fan_program_3.setLines(vectorOfLines); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_3.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //start program calling manager testing + EnergyManagementSystemProgramCallingManager fan_pcm(model); + fan_pcm.setName("Best Program Calling Manager"); + //get calling points + std::vector calling_points = fan_pcm.validCallingPointValues(); + + //check if BeginNewEnviornment is in callingpoints. + bool finds = (std::find(calling_points.begin(), calling_points.end(), "BeginNewEnvironment") != calling_points.end()); + EXPECT_EQ(true, finds); + + bool callpt = fan_pcm.setCallingPoint("BeginNewEnvironment"); + EXPECT_EQ(true, callpt); + EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint().get()); + + //should start with 0 programs + std::vector programs = fan_pcm.programs(); + EXPECT_EQ(0, programs.size()); + //should not be initialized yet + boost::optional program = fan_pcm.getProgram(1); + EXPECT_EQ(false, program.is_initialized()); + + bool add_result = fan_pcm.addProgram(fan_program_1); + EXPECT_EQ(true, add_result); + add_result = fan_pcm.addProgram(fan_program_2); + EXPECT_EQ(true, add_result); + EXPECT_EQ(2, fan_pcm.programs().size()); + EXPECT_EQ(fan_program_2.nameString(), fan_pcm.programs()[1].nameString()); + //set program one slot too big, will return false + bool insert_result = fan_pcm.setProgram(fan_program_3, 3); + EXPECT_EQ(false, insert_result); + //still only 2 programs + EXPECT_EQ(2, fan_pcm.programs().size()); + //set program in last slot + insert_result = fan_pcm.setProgram(fan_program_3, 2); + EXPECT_EQ(true, insert_result); + //3 programs + EXPECT_EQ(3, fan_pcm.programs().size()); + //check program name + program = fan_pcm.getProgram(0); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_1.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(2); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); + //set program 3 in program 2 slot moving the rest down + insert_result = fan_pcm.setProgram(fan_program_3, 1); + EXPECT_EQ(true, insert_result); + //now 4 programs + EXPECT_EQ(4, fan_pcm.programs().size()); + //check program name is now program 3's + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); + //erase program 3 in 2nd slot + bool erase_prog = fan_pcm.eraseProgram(1); + EXPECT_EQ(true, erase_prog); + //check for null programs + std::vector nullProgs = fan_pcm.nullPrograms(); + //should not be any if erasePrograms reindexed correctly + EXPECT_EQ(0, nullProgs.size()); + //check program name is back to program 2's + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); + + //erase all programs + fan_pcm.erasePrograms(); + //now 0 programs + EXPECT_EQ(0, fan_pcm.programs().size()); + + //create vector of programs + std::vector new_programs; + new_programs.push_back(fan_program_1); + new_programs.push_back(fan_program_2); + new_programs.push_back(fan_program_3); + //set vector of programs + insert_result = fan_pcm.setPrograms(new_programs); + //3 programs + EXPECT_EQ(3, fan_pcm.programs().size()); + //check program name + program = fan_pcm.getProgram(0); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_1.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(1); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); + //check program name + program = fan_pcm.getProgram(2); + EXPECT_EQ(true, program.is_initialized()); + EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); - openstudio::path outDir = resourcesPath() / openstudio::toPath("airLoopHVAC.idf"); - boost::filesystem::ofstream ofs(outDir); - workspace.toIdfFile().print(ofs); - ofs.close(); + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); + + model.save(toPath("./EMS_example.osm"), true); + workspace.save(toPath("./EMS_example.idf"), true); } -*/ From e8e16a931b7ace026c32913f3eb69c6f955f7ee5 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 23 Aug 2016 11:52:19 -0600 Subject: [PATCH 067/159] translate actuator --- ...ranslateEnergyManagementSystemActuator.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index 7867e558dc7..96a403415af 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -54,11 +54,28 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct } idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); - //TODO below does not work, try switch statement - idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.iddObjectType().valueName()); idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); + //TODO below does not work, try switch statement + //idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.iddObjectType().valueName()); + std::string n = modelObject.actuatedComponent().iddObject().name(); + IddObjectType x = modelObject.iddObject().type().value(); + + switch (modelObject.iddObject().type().value()) { + case openstudio::IddObjectType::OS_Fan_ConstantVolume: + { + n = "Fan"; + break; + } + case openstudio::IddObjectType::OS_ElectricEquipment : + { + n = "ElectricEquipment"; + break; + } + } + + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, n); return idfObject; } From fc69a580288ee5017609691390d2e2ccbed149e2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 23 Aug 2016 13:36:55 -0600 Subject: [PATCH 068/159] getting actuated componenet to translate need to expand switch statement --- .../ForwardTranslateEnergyManagementSystemActuator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index 96a403415af..ae20e7740f5 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -61,8 +61,10 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct std::string n = modelObject.actuatedComponent().iddObject().name(); IddObjectType x = modelObject.iddObject().type().value(); + IddObjectType y = modelObject.actuatedComponent().iddObject().type().value(); + IddObjectType z = openstudio::IddObjectType::OS_Fan_ConstantVolume; - switch (modelObject.iddObject().type().value()) { + switch (modelObject.actuatedComponent().iddObject().type().value()) { case openstudio::IddObjectType::OS_Fan_ConstantVolume: { n = "Fan"; From 9eabc98dd23de28e351e02c203a5387bbae397fc Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 24 Aug 2016 13:39:08 -0600 Subject: [PATCH 069/159] add ComponentType to Actuator add tests add forwardtranslation --- openstudiocore/resources/model/OpenStudio.idd | 7 ++++-- ...ranslateEnergyManagementSystemActuator.cpp | 24 ++----------------- .../src/energyplus/Test/EMS_GTest.cpp | 12 ++++++++++ .../model/EnergyManagementSystemActuator.cpp | 20 ++++++++++++++++ .../model/EnergyManagementSystemActuator.hpp | 4 ++++ .../EnergyManagementSystemActuator_Impl.hpp | 4 ++++ .../EnergyManagementSystemActuator_GTest.cpp | 5 ++++ ...ementSystemProgramCallingManager_GTest.cpp | 2 ++ .../EnergyManagementSystemProgram_GTest.cpp | 2 ++ 9 files changed, 56 insertions(+), 24 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 897472ccf52..fdce9b9b2da 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26410,9 +26410,12 @@ OS:EnergyManagementSystem:Actuator, \required-field \type object-list \object-list AllObjects - A4 ; \field Actuated Component Control Type + A4 , \field Actuated Component Type \required-field - \type alpha + \type alpha + A5 ; \field Actuated Component Control Type + \required-field + \type alpha OS:EnergyManagementSystem:ProgramCallingManager, \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index ae20e7740f5..f2a28d4b734 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -56,29 +56,9 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); - //TODO below does not work, try switch statement - //idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.iddObjectType().valueName()); - - std::string n = modelObject.actuatedComponent().iddObject().name(); - IddObjectType x = modelObject.iddObject().type().value(); - IddObjectType y = modelObject.actuatedComponent().iddObject().type().value(); - IddObjectType z = openstudio::IddObjectType::OS_Fan_ConstantVolume; - - switch (modelObject.actuatedComponent().iddObject().type().value()) { - case openstudio::IddObjectType::OS_Fan_ConstantVolume: - { - n = "Fan"; - break; - } - case openstudio::IddObjectType::OS_ElectricEquipment : - { - n = "ElectricEquipment"; - break; - } - } - idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, n); - + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); + return idfObject; } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 6f519254247..3bf3f799a0a 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -146,6 +146,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { fanActuator.setActuatedComponentControlType(fanControlType); EXPECT_EQ(fan, fanActuator.actuatedComponent()); EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); fanActuator.setActuatedComponent(fan2); EXPECT_EQ(fan2, fanActuator.actuatedComponent()); @@ -184,6 +187,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); //add program EnergyManagementSystemProgram fan_program_1(model); @@ -223,6 +229,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { fanActuator2.setName(fanName); fanControlType = "Fan Pressure Rise"; fanActuator2.setActuatedComponentControlType(fanControlType); + ComponentType = "Fan"; + fanActuator2.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, fanActuator2.actuatedComponentType()); // Create a second program from a vector of lines EnergyManagementSystemProgram fan_program_2(model); @@ -345,6 +354,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); //add program EnergyManagementSystemProgram fan_program_1(model); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index a06ad6a8bc0..cb7aa9d1e43 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -78,6 +78,12 @@ namespace detail { return value.get(); } + std::string EnergyManagementSystemActuator_Impl::actuatedComponentType() const { + boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, true); + OS_ASSERT(value); + return value.get(); + } + bool EnergyManagementSystemActuator_Impl::setActuatedComponent(const ModelObject& modelObject) { return setPointer(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentName, modelObject.handle()); } @@ -88,6 +94,12 @@ namespace detail { return result; } + bool EnergyManagementSystemActuator_Impl::setActuatedComponentType(const std::string& actuatedComponentType) { + bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, actuatedComponentType); + OS_ASSERT(result); + return result; + } + } // detail EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject) @@ -109,6 +121,10 @@ std::string EnergyManagementSystemActuator::actuatedComponentControlType() const return getImpl()->actuatedComponentControlType(); } +std::string EnergyManagementSystemActuator::actuatedComponentType() const { + return getImpl()->actuatedComponentType(); +} + bool EnergyManagementSystemActuator::setActuatedComponent(const ModelObject& modelObject) { return getImpl()->setActuatedComponent(modelObject); } @@ -117,6 +133,10 @@ bool EnergyManagementSystemActuator::setActuatedComponentControlType(const std:: return getImpl()->setActuatedComponentControlType(actuatedComponentControlType); } +bool EnergyManagementSystemActuator::setActuatedComponentType(const std::string& actuatedComponentType) { + return getImpl()->setActuatedComponentType(actuatedComponentType); +} + /// @cond EnergyManagementSystemActuator::EnergyManagementSystemActuator(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index d39faacaf92..e59e0f73801 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -53,6 +53,8 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { std::string actuatedComponentControlType() const; + std::string actuatedComponentType() const; + //@} /** @name Setters */ //@{ @@ -61,6 +63,8 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); + bool setActuatedComponentType(const std::string& actuatedComponentType); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp index f05e4aee02a..8bd06b752d7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator_Impl.hpp @@ -64,6 +64,8 @@ namespace detail { std::string actuatedComponentControlType() const; + std::string actuatedComponentType() const; + //@} /** @name Setters */ //@{ @@ -72,6 +74,8 @@ namespace detail { bool setActuatedComponentControlType(const std::string& actuatedComponentControlType); + bool setActuatedComponentType(const std::string& actuatedComponentType); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index 852a81ede87..f86875a7f80 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -62,9 +62,14 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); + EXPECT_EQ(fan, fanActuator.actuatedComponent()); EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); + fanActuator.setActuatedComponent(fan2); EXPECT_EQ(fan2, fanActuator.actuatedComponent()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp index e9a051e411c..afc23e90515 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp @@ -74,6 +74,8 @@ TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); //add program EnergyManagementSystemProgram fan_program_1(model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index d5e6583211a..51cfbbaef5c 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -72,6 +72,8 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); //add program EnergyManagementSystemProgram fan_program_1(model); From 5a46212e0b8c8eb02d249a017ac734c42c26f92d Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 24 Aug 2016 14:48:44 -0600 Subject: [PATCH 070/159] expand tests to outputMeters --- .../ruby/openstudio/model/test/Ems_Test.rb | 21 +++++++++++++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 14 +++++++++++++ .../EnergyManagementSystemActuator_GTest.cpp | 21 +++++++++++++++++++ .../EnergyManagementSystemSensor_GTest.cpp | 15 +++++++++++++ 4 files changed, 71 insertions(+) diff --git a/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb index 2780097ffed..8811806f301 100644 --- a/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb +++ b/openstudiocore/ruby/openstudio/model/test/Ems_Test.rb @@ -47,6 +47,17 @@ def test_ems assert_equal oat_sensor_name, oat_sensor.name.get.to_s assert_equal output_var, oat_sensor.outputVariable.get.variableName + meter = OpenStudio::Model::Meter.new(model) + meter.setName("test meter") + + meter_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model) + meter_sensor_name = "meter Sensor" + meter_sensor.setName(meter_sensor_name) + meter_sensor.setOutputMeter(meter) + + assert_equal meter_sensor_name, meter_sensor.name.get.to_s + assert_equal "test meter", meter_sensor.outputMeter.get.variableName + ### Actuator ### # Get the first fan from the example model @@ -59,11 +70,21 @@ def test_ems fan_actuator.setName("#{fan.name} Press Actuator") fan_press = "Fan Pressure Rise" fan_actuator.setActuatedComponentControlType(fan_press) + fan_actuator.setActuatedComponentType("fan") fan_actuator.setActuatedComponent(fan) # Assertions for actuator setters and getters assert_equal(fan, fan_actuator.actuatedComponent) assert_equal(fan_press, fan_actuator.actuatedComponentControlType) + assert_equal("fan", fan_actuator.actuatedComponentType) + + equip = OpenStudio::Model::ElectricEquipment.new(model) + # Create an actuator to set the elec equip + equip_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(equip) + equip_actuator.setName("#{equip.name} power level actuator") + equip_control = "Electric Power Level" + equip_actuator.setActuatedComponentControlType(equip_control) + equip_actuator.setActuatedComponentType("ElectricEquipment") ### Program ### diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 3bf3f799a0a..f53c35ccf3c 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -114,6 +114,20 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { EXPECT_EQ(zone1.name().get(), lights.keyName().get()); EXPECT_EQ("Light Sensor", lights.nameString()); + // create meter + OutputMeter meter(model); + meter.setName("test meter"); + + //add sensor to meter + EnergyManagementSystemSensor meter_sensor(model); + meter_sensor.setName("meter sensor"); + meter_sensor.setOutputMeter(meter); + + EXPECT_EQ("meter sensor", meter_sensor.nameString()); + EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); + EXPECT_EQ(meter, meter_sensor.outputMeter()); + EXPECT_EQ("", meter_sensor.keyName().get()); + //EXPECT_TRUE(model.getOptionalUniqueModelObject()) << "Example model does not include a Version object."; ForwardTranslator forwardTranslator; diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index f86875a7f80..263b3798079 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -25,6 +25,10 @@ #include "../ThermalZone.hpp" #include "../FanConstantVolume.hpp" #include "../FanConstantVolume_Impl.hpp" +#include "../ElectricEquipment.hpp" +#include "../ElectricEquipment_Impl.hpp" +#include "../ElectricEquipmentDefinition.hpp" +#include "../ElectricEquipmentDefinition_Impl.hpp" #include "../Schedule.hpp" #include "../EnergyManagementSystemActuator.hpp" #include "../OutputVariable.hpp" @@ -73,5 +77,22 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) fanActuator.setActuatedComponent(fan2); EXPECT_EQ(fan2, fanActuator.actuatedComponent()); + //add electric equipment actuator + ElectricEquipmentDefinition definition(model); + ElectricEquipment electricEquipment(definition); + EnergyManagementSystemActuator equipActuator(electricEquipment); + std::string equipName = electricEquipment.name().get() + "power level Actuator"; + equipActuator.setName(equipName); + std::string equipControlType = "Electric Power Level"; + equipActuator.setActuatedComponentControlType(equipControlType); + + EXPECT_EQ(electricEquipment, equipActuator.actuatedComponent()); + EXPECT_EQ(equipControlType, equipActuator.actuatedComponentControlType()); + + ComponentType = "ElectricEquipment"; + equipActuator.setActuatedComponentType(ComponentType); + EXPECT_EQ(ComponentType, equipActuator.actuatedComponentType()); + + } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 0719f396a98..6e950c5d086 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -26,6 +26,8 @@ #include "../EnergyManagementSystemSensor.hpp" #include "../OutputVariable.hpp" #include "../OutputVariable_Impl.hpp" +#include "../OutputMeter.hpp" +#include "../OutputMeter_Impl.hpp" #include "../Model_Impl.hpp" #include "../../utilities/idd/IddEnums.hpp" @@ -77,5 +79,18 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ(zone1.name().get(), lights.keyName().get()); EXPECT_EQ("Light Sensor", lights.nameString()); + // create meter + OutputMeter meter(model); + meter.setName("test meter"); + + //add sensor to meter + EnergyManagementSystemSensor meter_sensor(model); + meter_sensor.setName("meter sensor"); + meter_sensor.setOutputMeter(meter); + + EXPECT_EQ("meter sensor", meter_sensor.nameString()); + EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); + EXPECT_EQ(meter, meter_sensor.outputMeter()); + EXPECT_EQ("", meter_sensor.keyName().get()); } From 3bbe3eeb88c13e47ebfc178bd7974292d8eb785f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 24 Aug 2016 21:47:13 -0600 Subject: [PATCH 071/159] add stubs for remaining EMS objects --- developer/ruby/MakeModelObjects.rb | 16 +- openstudiocore/src/model/CMakeLists.txt | 24 ++ .../src/model/ConcreteModelObjects.hpp | 16 + ...agementSystemConstructionIndexVariable.cpp | 122 ++++++++ ...agementSystemConstructionIndexVariable.hpp | 95 ++++++ ...ntSystemConstructionIndexVariable_Impl.hpp | 98 ++++++ ...agementSystemCurveOrTableIndexVariable.cpp | 122 ++++++++ ...agementSystemCurveOrTableIndexVariable.hpp | 95 ++++++ ...ntSystemCurveOrTableIndexVariable_Impl.hpp | 98 ++++++ .../EnergyManagementSystemGlobalVariable.cpp | 89 ++++++ .../EnergyManagementSystemGlobalVariable.hpp | 90 ++++++ ...rgyManagementSystemGlobalVariable_Impl.hpp | 87 ++++++ ...EnergyManagementSystemInternalVariable.cpp | 135 ++++++++ ...EnergyManagementSystemInternalVariable.hpp | 96 ++++++ ...yManagementSystemInternalVariable_Impl.hpp | 93 ++++++ ...yManagementSystemMeteredOutputVariable.cpp | 293 ++++++++++++++++++ ...yManagementSystemMeteredOutputVariable.hpp | 132 ++++++++ ...gementSystemMeteredOutputVariable_Impl.hpp | 121 ++++++++ .../EnergyManagementSystemOutputVariable.cpp | 215 +++++++++++++ .../EnergyManagementSystemOutputVariable.hpp | 114 +++++++ ...rgyManagementSystemOutputVariable_Impl.hpp | 107 +++++++ .../EnergyManagementSystemSubroutine.cpp | 89 ++++++ .../EnergyManagementSystemSubroutine.hpp | 90 ++++++ .../EnergyManagementSystemSubroutine_Impl.hpp | 87 ++++++ .../EnergyManagementSystemTrendVariable.cpp | 131 ++++++++ .../EnergyManagementSystemTrendVariable.hpp | 94 ++++++ ...ergyManagementSystemTrendVariable_Impl.hpp | 91 ++++++ openstudiocore/src/model/Model.cpp | 16 + openstudiocore/src/model/ModelCore.i | 16 + 29 files changed, 2868 insertions(+), 4 deletions(-) create mode 100644 openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp create mode 100644 openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp diff --git a/developer/ruby/MakeModelObjects.rb b/developer/ruby/MakeModelObjects.rb index 5836f95fde5..a75edfccae3 100644 --- a/developer/ruby/MakeModelObjects.rb +++ b/developer/ruby/MakeModelObjects.rb @@ -84,10 +84,18 @@ # objects << ["OS:LightingDesignDay", "LightingDesignDay", "ModelObject"] # objects << ["OS:LightingSimulationControl", "LightingSimulationControl", "ModelObject"] -objects << ["OS:EnergyManagementSystem:Sensor", "EnergyManagementSystemSensor", "ModelObject"] -objects << ["OS:EnergyManagementSystem:Actuator", "EnergyManagementSystemActuator", "ModelObject"] -objects << ["OS:EnergyManagementSystem:ProgramCallingManager", "EnergyManagementSystemProgramCallingManager", "ModelObject"] -objects << ["OS:EnergyManagementSystem:Program", "EnergyManagementSystemProgram", "ModelObject"] +# objects << ["OS:EnergyManagementSystem:Sensor", "EnergyManagementSystemSensor", "ModelObject"] +# objects << ["OS:EnergyManagementSystem:Actuator", "EnergyManagementSystemActuator", "ModelObject"] +# objects << ["OS:EnergyManagementSystem:ProgramCallingManager", "EnergyManagementSystemProgramCallingManager", "ModelObject"] +# objects << ["OS:EnergyManagementSystem:Program", "EnergyManagementSystemProgram", "ModelObject"] +objects << ["OS:EnergyManagementSystem:GlobalVariable", "EnergyManagementSystemGlobalVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:Subroutine", "EnergyManagementSystemSubroutine", "ModelObject"] +objects << ["OS:EnergyManagementSystem:OutputVariable", "EnergyManagementSystemOutputVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:MeteredOutputVariable", "EnergyManagementSystemMeteredOutputVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:TrendVariable", "EnergyManagementSystemTrendVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:InternalVariable", "EnergyManagementSystemInternalVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:CurveOrTableIndexVariable", "EnergyManagementSystemCurveOrTableIndexVariable", "ModelObject"] +objects << ["OS:EnergyManagementSystem:ConstructionIndexVariable", "EnergyManagementSystemConstructionIndexVariable", "ModelObject"] includePath = nil if /mswin/.match(RUBY_PLATFORM) || /mingw/.match(RUBY_PLATFORM) diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 681d8dd7ceb..d1de996c55d 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -455,6 +455,24 @@ set(${target_name}_src EnergyManagementSystemActuator.cpp EnergyManagementSystemActuator.hpp EnergyManagementSystemActuator_Impl.hpp + EnergyManagementSystemConstructionIndexVariable.cpp + EnergyManagementSystemConstructionIndexVariable.hpp + EnergyManagementSystemConstructionIndexVariable_Impl.hpp + EnergyManagementSystemCurveOrTableIndexVariable.cpp + EnergyManagementSystemCurveOrTableIndexVariable.hpp + EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp + EnergyManagementSystemGlobalVariable.cpp + EnergyManagementSystemGlobalVariable.hpp + EnergyManagementSystemGlobalVariable_Impl.hpp + EnergyManagementSystemInternalVariable.cpp + EnergyManagementSystemInternalVariable.hpp + EnergyManagementSystemInternalVariable_Impl.hpp + EnergyManagementSystemMeteredOutputVariable.cpp + EnergyManagementSystemMeteredOutputVariable.hpp + EnergyManagementSystemMeteredOutputVariable_Impl.hpp + EnergyManagementSystemOutputVariable.cpp + EnergyManagementSystemOutputVariable.hpp + EnergyManagementSystemOutputVariable_Impl.hpp EnergyManagementSystemProgram.cpp EnergyManagementSystemProgram.hpp EnergyManagementSystemProgram_Impl.hpp @@ -464,6 +482,12 @@ set(${target_name}_src EnergyManagementSystemSensor.cpp EnergyManagementSystemSensor.hpp EnergyManagementSystemSensor_Impl.hpp + EnergyManagementSystemSubroutine.cpp + EnergyManagementSystemSubroutine.hpp + EnergyManagementSystemSubroutine_Impl.hpp + EnergyManagementSystemTrendVariable.cpp + EnergyManagementSystemTrendVariable.hpp + EnergyManagementSystemTrendVariable_Impl.hpp EvaporativeCoolerDirectResearchSpecial.hpp EvaporativeCoolerDirectResearchSpecial_Impl.hpp EvaporativeCoolerDirectResearchSpecial.cpp diff --git a/openstudiocore/src/model/ConcreteModelObjects.hpp b/openstudiocore/src/model/ConcreteModelObjects.hpp index 89056f79c19..89c407c6e9e 100644 --- a/openstudiocore/src/model/ConcreteModelObjects.hpp +++ b/openstudiocore/src/model/ConcreteModelObjects.hpp @@ -156,9 +156,17 @@ #include "ElectricLoadCenterInverterSimple.hpp" #include "ElectricLoadCenterStorageSimple.hpp" #include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemMeteredOutputVariable.hpp" +#include "EnergyManagementSystemOutputVariable.hpp" #include "EnergyManagementSystemProgram.hpp" #include "EnergyManagementSystemProgramCallingManager.hpp" #include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" #include "EvaporativeCoolerDirectResearchSpecial.hpp" #include "EvaporativeCoolerIndirectResearchSpecial.hpp" #include "EvaporativeFluidCoolerSingleSpeed.hpp" @@ -538,9 +546,17 @@ #include "ElectricLoadCenterInverterSimple_Impl.hpp" #include "ElectricLoadCenterStorageSimple_Impl.hpp" #include "EnergyManagementSystemActuator_Impl.hpp" +#include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "EnergyManagementSystemGlobalVariable_Impl.hpp" +#include "EnergyManagementSystemInternalVariable_Impl.hpp" +#include "EnergyManagementSystemMeteredOutputVariable_Impl.hpp" +#include "EnergyManagementSystemOutputVariable_Impl.hpp" #include "EnergyManagementSystemProgram_Impl.hpp" #include "EnergyManagementSystemProgramCallingManager_Impl.hpp" #include "EnergyManagementSystemSensor_Impl.hpp" +#include "EnergyManagementSystemSubroutine_Impl.hpp" +#include "EnergyManagementSystemTrendVariable_Impl.hpp" #include "EvaporativeCoolerDirectResearchSpecial_Impl.hpp" #include "EvaporativeCoolerIndirectResearchSpecial_Impl.hpp" #include "EvaporativeFluidCoolerSingleSpeed_Impl.hpp" diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp new file mode 100644 index 00000000000..3b8627577f9 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -0,0 +1,122 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemConstructionIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" + +// TODO: Check the following class names against object getters and setters. +#include "Construction.hpp" +#include "Construction_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemConstructionIndexVariable_Impl::EnergyManagementSystemConstructionIndexVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemConstructionIndexVariable::iddObjectType()); + } + + EnergyManagementSystemConstructionIndexVariable_Impl::EnergyManagementSystemConstructionIndexVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemConstructionIndexVariable::iddObjectType()); + } + + EnergyManagementSystemConstructionIndexVariable_Impl::EnergyManagementSystemConstructionIndexVariable_Impl(const EnergyManagementSystemConstructionIndexVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemConstructionIndexVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemConstructionIndexVariable_Impl::iddObjectType() const { + return EnergyManagementSystemConstructionIndexVariable::iddObjectType(); + } + + Construction EnergyManagementSystemConstructionIndexVariable_Impl::constructionObject() const { + boost::optional value = optionalConstructionObject(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Construction Object attached."); + } + return value.get(); + } + + bool EnergyManagementSystemConstructionIndexVariable_Impl::setConstructionObject(const Construction& construction) { + bool result = setPointer(OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName, construction.handle()); + return result; + } + + boost::optional EnergyManagementSystemConstructionIndexVariable_Impl::optionalConstructionObject() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); + } + +} // detail + +EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model) + : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName + bool ok = true; + // ok = setConstructionObject(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemConstructionIndexVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable); +} + +Construction EnergyManagementSystemConstructionIndexVariable::constructionObject() const { + return getImpl()->constructionObject(); +} + +bool EnergyManagementSystemConstructionIndexVariable::setConstructionObject(const Construction& construction) { + return getImpl()->setConstructionObject(construction); +} + +/// @cond +EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp new file mode 100644 index 00000000000..e6a0980f064 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp @@ -0,0 +1,95 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class Construction; + +namespace detail { + + class EnergyManagementSystemConstructionIndexVariable_Impl; + +} // detail + +/** EnergyManagementSystemConstructionIndexVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:ConstructionIndexVariable'. */ +class MODEL_API EnergyManagementSystemConstructionIndexVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemConstructionIndexVariable(const Model& model); + + virtual ~EnergyManagementSystemConstructionIndexVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: Construction. + Construction constructionObject() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: Construction. + bool setConstructionObject(const Construction& construction); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemConstructionIndexVariable_Impl ImplType; + + explicit EnergyManagementSystemConstructionIndexVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemConstructionIndexVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemConstructionIndexVariable"); +}; + +/** \relates EnergyManagementSystemConstructionIndexVariable*/ +typedef boost::optional OptionalEnergyManagementSystemConstructionIndexVariable; + +/** \relates EnergyManagementSystemConstructionIndexVariable*/ +typedef std::vector EnergyManagementSystemConstructionIndexVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp new file mode 100644 index 00000000000..b50790ff072 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp @@ -0,0 +1,98 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class Construction; + +namespace detail { + + /** EnergyManagementSystemConstructionIndexVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemConstructionIndexVariable.*/ + class MODEL_API EnergyManagementSystemConstructionIndexVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemConstructionIndexVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemConstructionIndexVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemConstructionIndexVariable_Impl(const EnergyManagementSystemConstructionIndexVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemConstructionIndexVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: Construction. + Construction constructionObject() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: Construction. + bool setConstructionObject(const Construction& construction); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemConstructionIndexVariable"); + + // TODO: Check the return types of these methods. + // Optional getters for use by methods like children() so can remove() if the constructor fails. + // There are other ways for the public versions of these getters to fail--perhaps all required + // objects should be returned as boost::optionals + boost::optional optionalConstructionObject() const; + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMCONSTRUCTIONINDEXVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp new file mode 100644 index 00000000000..34f15678370 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -0,0 +1,122 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" + +// TODO: Check the following class names against object getters and setters. +//#include "AllCurves.hpp" +//#include "AllCurves_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType()); + } + + EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType()); + } + + EnergyManagementSystemCurveOrTableIndexVariable_Impl::EnergyManagementSystemCurveOrTableIndexVariable_Impl(const EnergyManagementSystemCurveOrTableIndexVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemCurveOrTableIndexVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemCurveOrTableIndexVariable_Impl::iddObjectType() const { + return EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(); + } + + ModelObject EnergyManagementSystemCurveOrTableIndexVariable_Impl::curveorTableObject() const { + boost::optional value = optionalCurveorTableObject(); + if (!value) { + LOG_AND_THROW(briefDescription() << " does not have an Curveor Table Object attached."); + } + return value.get(); + } + + bool EnergyManagementSystemCurveOrTableIndexVariable_Impl::setCurveorTableObject(const ModelObject& allCurves) { + bool result = setPointer(OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, allCurves.handle()); + return result; + } + + boost::optional EnergyManagementSystemCurveOrTableIndexVariable_Impl::optionalCurveorTableObject() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); + } + +} // detail + +EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model) + : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName + bool ok = true; + // ok = setCurveorTableObject(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable); +} + +ModelObject EnergyManagementSystemCurveOrTableIndexVariable::curveorTableObject() const { + return getImpl()->curveorTableObject(); +} + +bool EnergyManagementSystemCurveOrTableIndexVariable::setCurveorTableObject(const ModelObject& allCurves) { + return getImpl()->setCurveorTableObject(allCurves); +} + +/// @cond +EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp new file mode 100644 index 00000000000..743615a4f7c --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp @@ -0,0 +1,95 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class AllCurves; + +namespace detail { + + class EnergyManagementSystemCurveOrTableIndexVariable_Impl; + +} // detail + +/** EnergyManagementSystemCurveOrTableIndexVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:CurveOrTableIndexVariable'. */ +class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model); + + virtual ~EnergyManagementSystemCurveOrTableIndexVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: AllCurves. + ModelObject curveorTableObject() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: AllCurves. + bool setCurveorTableObject(const ModelObject& allCurves); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl ImplType; + + explicit EnergyManagementSystemCurveOrTableIndexVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemCurveOrTableIndexVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemCurveOrTableIndexVariable"); +}; + +/** \relates EnergyManagementSystemCurveOrTableIndexVariable*/ +typedef boost::optional OptionalEnergyManagementSystemCurveOrTableIndexVariable; + +/** \relates EnergyManagementSystemCurveOrTableIndexVariable*/ +typedef std::vector EnergyManagementSystemCurveOrTableIndexVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp new file mode 100644 index 00000000000..60115e17ba9 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp @@ -0,0 +1,98 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +// TODO: Check the following class names against object getters and setters. +class AllCurves; + +namespace detail { + + /** EnergyManagementSystemCurveOrTableIndexVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemCurveOrTableIndexVariable.*/ + class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemCurveOrTableIndexVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemCurveOrTableIndexVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemCurveOrTableIndexVariable_Impl(const EnergyManagementSystemCurveOrTableIndexVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemCurveOrTableIndexVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + // TODO: Check return type. From object lists, some candidates are: AllCurves. + ModelObject curveorTableObject() const; + + //@} + /** @name Setters */ + //@{ + + // TODO: Check argument type. From object lists, some candidates are: AllCurves. + bool setCurveorTableObject(const ModelObject& allCurves); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemCurveOrTableIndexVariable"); + + // TODO: Check the return types of these methods. + // Optional getters for use by methods like children() so can remove() if the constructor fails. + // There are other ways for the public versions of these getters to fail--perhaps all required + // objects should be returned as boost::optionals + boost::optional optionalCurveorTableObject() const; + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMCURVEORTABLEINDEXVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp new file mode 100644 index 00000000000..a2db180cb90 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -0,0 +1,89 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemGlobalVariable_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemGlobalVariable_Impl::EnergyManagementSystemGlobalVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemGlobalVariable::iddObjectType()); + } + + EnergyManagementSystemGlobalVariable_Impl::EnergyManagementSystemGlobalVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemGlobalVariable::iddObjectType()); + } + + EnergyManagementSystemGlobalVariable_Impl::EnergyManagementSystemGlobalVariable_Impl(const EnergyManagementSystemGlobalVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemGlobalVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemGlobalVariable_Impl::iddObjectType() const { + return EnergyManagementSystemGlobalVariable::iddObjectType(); + } + +} // detail + +EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const Model& model) + : ModelObject(EnergyManagementSystemGlobalVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. +} + +IddObjectType EnergyManagementSystemGlobalVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); +} + +/// @cond +EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp new file mode 100644 index 00000000000..4a35f1571ab --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -0,0 +1,90 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemGlobalVariable_Impl; + +} // detail + +/** EnergyManagementSystemGlobalVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:GlobalVariable'. */ +class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemGlobalVariable(const Model& model); + + virtual ~EnergyManagementSystemGlobalVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemGlobalVariable_Impl ImplType; + + explicit EnergyManagementSystemGlobalVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemGlobalVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemGlobalVariable"); +}; + +/** \relates EnergyManagementSystemGlobalVariable*/ +typedef boost::optional OptionalEnergyManagementSystemGlobalVariable; + +/** \relates EnergyManagementSystemGlobalVariable*/ +typedef std::vector EnergyManagementSystemGlobalVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp new file mode 100644 index 00000000000..fc271ad3e4f --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp @@ -0,0 +1,87 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemGlobalVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemGlobalVariable.*/ + class MODEL_API EnergyManagementSystemGlobalVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemGlobalVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemGlobalVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemGlobalVariable_Impl(const EnergyManagementSystemGlobalVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemGlobalVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemGlobalVariable"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMGLOBALVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp new file mode 100644 index 00000000000..53a28473df1 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -0,0 +1,135 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemInternalVariable_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemInternalVariable_Impl::EnergyManagementSystemInternalVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemInternalVariable::iddObjectType()); + } + + EnergyManagementSystemInternalVariable_Impl::EnergyManagementSystemInternalVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemInternalVariable::iddObjectType()); + } + + EnergyManagementSystemInternalVariable_Impl::EnergyManagementSystemInternalVariable_Impl(const EnergyManagementSystemInternalVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemInternalVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemInternalVariable_Impl::iddObjectType() const { + return EnergyManagementSystemInternalVariable::iddObjectType(); + } + + boost::optional EnergyManagementSystemInternalVariable_Impl::internalDataIndexKeyName() const { + return getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName,true); + } + + std::string EnergyManagementSystemInternalVariable_Impl::internalDataType() const { + boost::optional value = getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType,true); + OS_ASSERT(value); + return value.get(); + } + + void EnergyManagementSystemInternalVariable_Impl::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { + bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, internalDataIndexKeyName); + OS_ASSERT(result); + } + + void EnergyManagementSystemInternalVariable_Impl::resetInternalDataIndexKeyName() { + bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, ""); + OS_ASSERT(result); + } + + void EnergyManagementSystemInternalVariable_Impl::setInternalDataType(const std::string& internalDataType) { + bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType, internalDataType); + OS_ASSERT(result); + } + +} // detail + +EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(const Model& model) + : ModelObject(EnergyManagementSystemInternalVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // setInternalDataType(); +} + +IddObjectType EnergyManagementSystemInternalVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_InternalVariable); +} + +boost::optional EnergyManagementSystemInternalVariable::internalDataIndexKeyName() const { + return getImpl()->internalDataIndexKeyName(); +} + +std::string EnergyManagementSystemInternalVariable::internalDataType() const { + return getImpl()->internalDataType(); +} + +void EnergyManagementSystemInternalVariable::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { + getImpl()->setInternalDataIndexKeyName(internalDataIndexKeyName); +} + +void EnergyManagementSystemInternalVariable::resetInternalDataIndexKeyName() { + getImpl()->resetInternalDataIndexKeyName(); +} + +void EnergyManagementSystemInternalVariable::setInternalDataType(const std::string& internalDataType) { + getImpl()->setInternalDataType(internalDataType); +} + +/// @cond +EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp new file mode 100644 index 00000000000..e7ec12ce554 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -0,0 +1,96 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemInternalVariable_Impl; + +} // detail + +/** EnergyManagementSystemInternalVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:InternalVariable'. */ +class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemInternalVariable(const Model& model); + + virtual ~EnergyManagementSystemInternalVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + boost::optional internalDataIndexKeyName() const; + + std::string internalDataType() const; + + //@} + /** @name Setters */ + //@{ + + void setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); + + void resetInternalDataIndexKeyName(); + + void setInternalDataType(const std::string& internalDataType); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemInternalVariable_Impl ImplType; + + explicit EnergyManagementSystemInternalVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemInternalVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemInternalVariable"); +}; + +/** \relates EnergyManagementSystemInternalVariable*/ +typedef boost::optional OptionalEnergyManagementSystemInternalVariable; + +/** \relates EnergyManagementSystemInternalVariable*/ +typedef std::vector EnergyManagementSystemInternalVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp new file mode 100644 index 00000000000..ff6f249cc8e --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp @@ -0,0 +1,93 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemInternalVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemInternalVariable.*/ + class MODEL_API EnergyManagementSystemInternalVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemInternalVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemInternalVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemInternalVariable_Impl(const EnergyManagementSystemInternalVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemInternalVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + boost::optional internalDataIndexKeyName() const; + + std::string internalDataType() const; + + //@} + /** @name Setters */ + //@{ + + void setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); + + void resetInternalDataIndexKeyName(); + + void setInternalDataType(const std::string& internalDataType); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemInternalVariable"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMINTERNALVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp new file mode 100644 index 00000000000..b525b859db3 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -0,0 +1,293 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemMeteredOutputVariable.hpp" +#include "EnergyManagementSystemMeteredOutputVariable_Impl.hpp" + +#include +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemMeteredOutputVariable_Impl::EnergyManagementSystemMeteredOutputVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemMeteredOutputVariable::iddObjectType()); + } + + EnergyManagementSystemMeteredOutputVariable_Impl::EnergyManagementSystemMeteredOutputVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemMeteredOutputVariable::iddObjectType()); + } + + EnergyManagementSystemMeteredOutputVariable_Impl::EnergyManagementSystemMeteredOutputVariable_Impl(const EnergyManagementSystemMeteredOutputVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemMeteredOutputVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemMeteredOutputVariable_Impl::iddObjectType() const { + return EnergyManagementSystemMeteredOutputVariable::iddObjectType(); + } + + std::string EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableName() const { + boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemMeteredOutputVariable_Impl::updateFrequency() const { + boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency,true); + OS_ASSERT(value); + return value.get(); + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSProgramorSubroutineName() const { + return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName,true); + } + + std::string EnergyManagementSystemMeteredOutputVariable_Impl::resourceType() const { + boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::ResourceType,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemMeteredOutputVariable_Impl::groupType() const { + boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::GroupType,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemMeteredOutputVariable_Impl::endUseCategory() const { + boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory,true); + OS_ASSERT(value); + return value.get(); + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::endUseSubcategory() const { + return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory,true); + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::units() const { + return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units,true); + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, eMSVariableName); + OS_ASSERT(result); + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, updateFrequency); + return result; + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, eMSProgramorSubroutineName); + OS_ASSERT(result); + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, ""); + OS_ASSERT(result); + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setResourceType(const std::string& resourceType) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::ResourceType, resourceType); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setGroupType(const std::string& groupType) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::GroupType, groupType); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEndUseCategory(const std::string& endUseCategory) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory, endUseCategory); + return result; + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, endUseSubcategory); + OS_ASSERT(result); + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::resetEndUseSubcategory() { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, ""); + OS_ASSERT(result); + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::setUnits(const std::string& units) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, units); + OS_ASSERT(result); + } + + void EnergyManagementSystemMeteredOutputVariable_Impl::resetUnits() { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, ""); + OS_ASSERT(result); + } + +} // detail + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // setEMSVariableName(); + bool ok = true; + // ok = setUpdateFrequency(); + OS_ASSERT(ok); + // ok = setResourceType(); + OS_ASSERT(ok); + // ok = setGroupType(); + OS_ASSERT(ok); + // ok = setEndUseCategory(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemMeteredOutputVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_MeteredOutputVariable); +} + +std::vector EnergyManagementSystemMeteredOutputVariable::updateFrequencyValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency); +} + +std::vector EnergyManagementSystemMeteredOutputVariable::resourceTypeValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_MeteredOutputVariableFields::ResourceType); +} + +std::vector EnergyManagementSystemMeteredOutputVariable::groupTypeValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_MeteredOutputVariableFields::GroupType); +} + +std::vector EnergyManagementSystemMeteredOutputVariable::endUseCategoryValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory); +} + +std::string EnergyManagementSystemMeteredOutputVariable::eMSVariableName() const { + return getImpl()->eMSVariableName(); +} + +std::string EnergyManagementSystemMeteredOutputVariable::updateFrequency() const { + return getImpl()->updateFrequency(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::eMSProgramorSubroutineName() const { + return getImpl()->eMSProgramorSubroutineName(); +} + +std::string EnergyManagementSystemMeteredOutputVariable::resourceType() const { + return getImpl()->resourceType(); +} + +std::string EnergyManagementSystemMeteredOutputVariable::groupType() const { + return getImpl()->groupType(); +} + +std::string EnergyManagementSystemMeteredOutputVariable::endUseCategory() const { + return getImpl()->endUseCategory(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::endUseSubcategory() const { + return getImpl()->endUseSubcategory(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::units() const { + return getImpl()->units(); +} + +void EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + getImpl()->setEMSVariableName(eMSVariableName); +} + +bool EnergyManagementSystemMeteredOutputVariable::setUpdateFrequency(const std::string& updateFrequency) { + return getImpl()->setUpdateFrequency(updateFrequency); +} + +void EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); +} + +void EnergyManagementSystemMeteredOutputVariable::resetEMSProgramorSubroutineName() { + getImpl()->resetEMSProgramorSubroutineName(); +} + +bool EnergyManagementSystemMeteredOutputVariable::setResourceType(const std::string& resourceType) { + return getImpl()->setResourceType(resourceType); +} + +bool EnergyManagementSystemMeteredOutputVariable::setGroupType(const std::string& groupType) { + return getImpl()->setGroupType(groupType); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEndUseCategory(const std::string& endUseCategory) { + return getImpl()->setEndUseCategory(endUseCategory); +} + +void EnergyManagementSystemMeteredOutputVariable::setEndUseSubcategory(const std::string& endUseSubcategory) { + getImpl()->setEndUseSubcategory(endUseSubcategory); +} + +void EnergyManagementSystemMeteredOutputVariable::resetEndUseSubcategory() { + getImpl()->resetEndUseSubcategory(); +} + +void EnergyManagementSystemMeteredOutputVariable::setUnits(const std::string& units) { + getImpl()->setUnits(units); +} + +void EnergyManagementSystemMeteredOutputVariable::resetUnits() { + getImpl()->resetUnits(); +} + +/// @cond +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp new file mode 100644 index 00000000000..f947b54113a --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -0,0 +1,132 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemMeteredOutputVariable_Impl; + +} // detail + +/** EnergyManagementSystemMeteredOutputVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:MeteredOutputVariable'. */ +class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model); + + virtual ~EnergyManagementSystemMeteredOutputVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + static std::vector updateFrequencyValues(); + + static std::vector resourceTypeValues(); + + static std::vector groupTypeValues(); + + static std::vector endUseCategoryValues(); + + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + std::string updateFrequency() const; + + boost::optional eMSProgramorSubroutineName() const; + + std::string resourceType() const; + + std::string groupType() const; + + std::string endUseCategory() const; + + boost::optional endUseSubcategory() const; + + boost::optional units() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setUpdateFrequency(const std::string& updateFrequency); + + void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + + void resetEMSProgramorSubroutineName(); + + bool setResourceType(const std::string& resourceType); + + bool setGroupType(const std::string& groupType); + + bool setEndUseCategory(const std::string& endUseCategory); + + void setEndUseSubcategory(const std::string& endUseSubcategory); + + void resetEndUseSubcategory(); + + void setUnits(const std::string& units); + + void resetUnits(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemMeteredOutputVariable_Impl ImplType; + + explicit EnergyManagementSystemMeteredOutputVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemMeteredOutputVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemMeteredOutputVariable"); +}; + +/** \relates EnergyManagementSystemMeteredOutputVariable*/ +typedef boost::optional OptionalEnergyManagementSystemMeteredOutputVariable; + +/** \relates EnergyManagementSystemMeteredOutputVariable*/ +typedef std::vector EnergyManagementSystemMeteredOutputVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp new file mode 100644 index 00000000000..63b3ea72f4a --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp @@ -0,0 +1,121 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemMeteredOutputVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemMeteredOutputVariable.*/ + class MODEL_API EnergyManagementSystemMeteredOutputVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemMeteredOutputVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemMeteredOutputVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemMeteredOutputVariable_Impl(const EnergyManagementSystemMeteredOutputVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemMeteredOutputVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + std::string updateFrequency() const; + + boost::optional eMSProgramorSubroutineName() const; + + std::string resourceType() const; + + std::string groupType() const; + + std::string endUseCategory() const; + + boost::optional endUseSubcategory() const; + + boost::optional units() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setUpdateFrequency(const std::string& updateFrequency); + + void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + + void resetEMSProgramorSubroutineName(); + + bool setResourceType(const std::string& resourceType); + + bool setGroupType(const std::string& groupType); + + bool setEndUseCategory(const std::string& endUseCategory); + + void setEndUseSubcategory(const std::string& endUseSubcategory); + + void resetEndUseSubcategory(); + + void setUnits(const std::string& units); + + void resetUnits(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemMeteredOutputVariable"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMMETEREDOUTPUTVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp new file mode 100644 index 00000000000..1a41ba56ce6 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -0,0 +1,215 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemOutputVariable.hpp" +#include "EnergyManagementSystemOutputVariable_Impl.hpp" + +#include +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemOutputVariable_Impl::EnergyManagementSystemOutputVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemOutputVariable::iddObjectType()); + } + + EnergyManagementSystemOutputVariable_Impl::EnergyManagementSystemOutputVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemOutputVariable::iddObjectType()); + } + + EnergyManagementSystemOutputVariable_Impl::EnergyManagementSystemOutputVariable_Impl(const EnergyManagementSystemOutputVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemOutputVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemOutputVariable_Impl::iddObjectType() const { + return EnergyManagementSystemOutputVariable::iddObjectType(); + } + + std::string EnergyManagementSystemOutputVariable_Impl::eMSVariableName() const { + boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemOutputVariable_Impl::typeofDatainVariable() const { + boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable,true); + OS_ASSERT(value); + return value.get(); + } + + std::string EnergyManagementSystemOutputVariable_Impl::updateFrequency() const { + boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency,true); + OS_ASSERT(value); + return value.get(); + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::eMSProgramorSubroutineName() const { + return getString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName,true); + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::units() const { + return getString(OS_EnergyManagementSystem_OutputVariableFields::Units,true); + } + + void EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, eMSVariableName); + OS_ASSERT(result); + } + + bool EnergyManagementSystemOutputVariable_Impl::setTypeofDatainVariable(const std::string& typeofDatainVariable) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable, typeofDatainVariable); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency, updateFrequency); + return result; + } + + void EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, eMSProgramorSubroutineName); + OS_ASSERT(result); + } + + void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, ""); + OS_ASSERT(result); + } + + void EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, units); + OS_ASSERT(result); + } + + void EnergyManagementSystemOutputVariable_Impl::resetUnits() { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, ""); + OS_ASSERT(result); + } + +} // detail + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // setEMSVariableName(); + bool ok = true; + // ok = setTypeofDatainVariable(); + OS_ASSERT(ok); + // ok = setUpdateFrequency(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_OutputVariable); +} + +std::vector EnergyManagementSystemOutputVariable::typeofDatainVariableValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable); +} + +std::vector EnergyManagementSystemOutputVariable::updateFrequencyValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency); +} + +std::string EnergyManagementSystemOutputVariable::eMSVariableName() const { + return getImpl()->eMSVariableName(); +} + +std::string EnergyManagementSystemOutputVariable::typeofDatainVariable() const { + return getImpl()->typeofDatainVariable(); +} + +std::string EnergyManagementSystemOutputVariable::updateFrequency() const { + return getImpl()->updateFrequency(); +} + +boost::optional EnergyManagementSystemOutputVariable::eMSProgramorSubroutineName() const { + return getImpl()->eMSProgramorSubroutineName(); +} + +boost::optional EnergyManagementSystemOutputVariable::units() const { + return getImpl()->units(); +} + +void EnergyManagementSystemOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + getImpl()->setEMSVariableName(eMSVariableName); +} + +bool EnergyManagementSystemOutputVariable::setTypeofDatainVariable(const std::string& typeofDatainVariable) { + return getImpl()->setTypeofDatainVariable(typeofDatainVariable); +} + +bool EnergyManagementSystemOutputVariable::setUpdateFrequency(const std::string& updateFrequency) { + return getImpl()->setUpdateFrequency(updateFrequency); +} + +void EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); +} + +void EnergyManagementSystemOutputVariable::resetEMSProgramorSubroutineName() { + getImpl()->resetEMSProgramorSubroutineName(); +} + +void EnergyManagementSystemOutputVariable::setUnits(const std::string& units) { + getImpl()->setUnits(units); +} + +void EnergyManagementSystemOutputVariable::resetUnits() { + getImpl()->resetUnits(); +} + +/// @cond +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp new file mode 100644 index 00000000000..03923623804 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -0,0 +1,114 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemOutputVariable_Impl; + +} // detail + +/** EnergyManagementSystemOutputVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:OutputVariable'. */ +class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemOutputVariable(const Model& model); + + virtual ~EnergyManagementSystemOutputVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + static std::vector typeofDatainVariableValues(); + + static std::vector updateFrequencyValues(); + + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + std::string typeofDatainVariable() const; + + std::string updateFrequency() const; + + boost::optional eMSProgramorSubroutineName() const; + + boost::optional units() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setTypeofDatainVariable(const std::string& typeofDatainVariable); + + bool setUpdateFrequency(const std::string& updateFrequency); + + void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + + void resetEMSProgramorSubroutineName(); + + void setUnits(const std::string& units); + + void resetUnits(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemOutputVariable_Impl ImplType; + + explicit EnergyManagementSystemOutputVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemOutputVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemOutputVariable"); +}; + +/** \relates EnergyManagementSystemOutputVariable*/ +typedef boost::optional OptionalEnergyManagementSystemOutputVariable; + +/** \relates EnergyManagementSystemOutputVariable*/ +typedef std::vector EnergyManagementSystemOutputVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp new file mode 100644 index 00000000000..7fc4ac431d5 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp @@ -0,0 +1,107 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemOutputVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemOutputVariable.*/ + class MODEL_API EnergyManagementSystemOutputVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemOutputVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemOutputVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemOutputVariable_Impl(const EnergyManagementSystemOutputVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemOutputVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + std::string typeofDatainVariable() const; + + std::string updateFrequency() const; + + boost::optional eMSProgramorSubroutineName() const; + + boost::optional units() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setTypeofDatainVariable(const std::string& typeofDatainVariable); + + bool setUpdateFrequency(const std::string& updateFrequency); + + void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + + void resetEMSProgramorSubroutineName(); + + void setUnits(const std::string& units); + + void resetUnits(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemOutputVariable"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMOUTPUTVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp new file mode 100644 index 00000000000..922da54700f --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -0,0 +1,89 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemSubroutine_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemSubroutine::iddObjectType()); + } + + EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemSubroutine::iddObjectType()); + } + + EnergyManagementSystemSubroutine_Impl::EnergyManagementSystemSubroutine_Impl(const EnergyManagementSystemSubroutine_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemSubroutine_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemSubroutine_Impl::iddObjectType() const { + return EnergyManagementSystemSubroutine::iddObjectType(); + } + +} // detail + +EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(const Model& model) + : ModelObject(EnergyManagementSystemSubroutine::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. +} + +IddObjectType EnergyManagementSystemSubroutine::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Subroutine); +} + +/// @cond +EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp new file mode 100644 index 00000000000..e26ebcba259 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp @@ -0,0 +1,90 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemSubroutine_Impl; + +} // detail + +/** EnergyManagementSystemSubroutine is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:Subroutine'. */ +class MODEL_API EnergyManagementSystemSubroutine : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemSubroutine(const Model& model); + + virtual ~EnergyManagementSystemSubroutine() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemSubroutine_Impl ImplType; + + explicit EnergyManagementSystemSubroutine(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemSubroutine_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSubroutine"); +}; + +/** \relates EnergyManagementSystemSubroutine*/ +typedef boost::optional OptionalEnergyManagementSystemSubroutine; + +/** \relates EnergyManagementSystemSubroutine*/ +typedef std::vector EnergyManagementSystemSubroutineVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp new file mode 100644 index 00000000000..60e82880269 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp @@ -0,0 +1,87 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemSubroutine_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemSubroutine.*/ + class MODEL_API EnergyManagementSystemSubroutine_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemSubroutine_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemSubroutine_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemSubroutine_Impl(const EnergyManagementSystemSubroutine_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemSubroutine_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Setters */ + //@{ + + // TODO: Handle this object's extensible fields. + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSubroutine"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMSUBROUTINE_IMPL_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp new file mode 100644 index 00000000000..bb3012f0f52 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -0,0 +1,131 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemTrendVariable_Impl.hpp" + +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + EnergyManagementSystemTrendVariable_Impl::EnergyManagementSystemTrendVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == EnergyManagementSystemTrendVariable::iddObjectType()); + } + + EnergyManagementSystemTrendVariable_Impl::EnergyManagementSystemTrendVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == EnergyManagementSystemTrendVariable::iddObjectType()); + } + + EnergyManagementSystemTrendVariable_Impl::EnergyManagementSystemTrendVariable_Impl(const EnergyManagementSystemTrendVariable_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& EnergyManagementSystemTrendVariable_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType EnergyManagementSystemTrendVariable_Impl::iddObjectType() const { + return EnergyManagementSystemTrendVariable::iddObjectType(); + } + + std::string EnergyManagementSystemTrendVariable_Impl::eMSVariableName() const { + boost::optional value = getString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName,true); + OS_ASSERT(value); + return value.get(); + } + + int EnergyManagementSystemTrendVariable_Impl::numberofTimestepstobeLogged() const { + boost::optional value = getInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged,true); + OS_ASSERT(value); + return value.get(); + } + + void EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, eMSVariableName); + OS_ASSERT(result); + } + + bool EnergyManagementSystemTrendVariable_Impl::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { + bool result = setInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, numberofTimestepstobeLogged); + return result; + } + +} // detail + +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) +{ + OS_ASSERT(getImpl()); + + // TODO: Appropriately handle the following required object-list fields. + // setEMSVariableName(); + bool ok = true; + // ok = setNumberofTimestepstobeLogged(); + OS_ASSERT(ok); +} + +IddObjectType EnergyManagementSystemTrendVariable::iddObjectType() { + return IddObjectType(IddObjectType::OS_EnergyManagementSystem_TrendVariable); +} + +std::string EnergyManagementSystemTrendVariable::eMSVariableName() const { + return getImpl()->eMSVariableName(); +} + +int EnergyManagementSystemTrendVariable::numberofTimestepstobeLogged() const { + return getImpl()->numberofTimestepstobeLogged(); +} + +void EnergyManagementSystemTrendVariable::setEMSVariableName(const std::string& eMSVariableName) { + getImpl()->setEMSVariableName(eMSVariableName); +} + +bool EnergyManagementSystemTrendVariable::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { + return getImpl()->setNumberofTimestepstobeLogged(numberofTimestepstobeLogged); +} + +/// @cond +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(std::shared_ptr impl) + : ModelObject(impl) +{} +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp new file mode 100644 index 00000000000..ed796225fc2 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -0,0 +1,94 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class EnergyManagementSystemTrendVariable_Impl; + +} // detail + +/** EnergyManagementSystemTrendVariable is a ModelObject that wraps the OpenStudio IDD object 'OS:EnergyManagementSystem:TrendVariable'. */ +class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + explicit EnergyManagementSystemTrendVariable(const Model& model); + + virtual ~EnergyManagementSystemTrendVariable() {} + + //@} + + static IddObjectType iddObjectType(); + + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + int numberofTimestepstobeLogged() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::EnergyManagementSystemTrendVariable_Impl ImplType; + + explicit EnergyManagementSystemTrendVariable(std::shared_ptr impl); + + friend class detail::EnergyManagementSystemTrendVariable_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemTrendVariable"); +}; + +/** \relates EnergyManagementSystemTrendVariable*/ +typedef boost::optional OptionalEnergyManagementSystemTrendVariable; + +/** \relates EnergyManagementSystemTrendVariable*/ +typedef std::vector EnergyManagementSystemTrendVariableVector; + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_HPP + diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp new file mode 100644 index 00000000000..060ddd0da16 --- /dev/null +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp @@ -0,0 +1,91 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_IMPL_HPP +#define MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** EnergyManagementSystemTrendVariable_Impl is a ModelObject_Impl that is the implementation class for EnergyManagementSystemTrendVariable.*/ + class MODEL_API EnergyManagementSystemTrendVariable_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + EnergyManagementSystemTrendVariable_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemTrendVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + EnergyManagementSystemTrendVariable_Impl(const EnergyManagementSystemTrendVariable_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~EnergyManagementSystemTrendVariable_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + std::string eMSVariableName() const; + + int numberofTimestepstobeLogged() const; + + //@} + /** @name Setters */ + //@{ + + void setEMSVariableName(const std::string& eMSVariableName); + + bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.EnergyManagementSystemTrendVariable"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_ENERGYMANAGEMENTSYSTEMTRENDVARIABLE_IMPL_HPP + diff --git a/openstudiocore/src/model/Model.cpp b/openstudiocore/src/model/Model.cpp index 58a48f488da..3af3e15f0aa 100644 --- a/openstudiocore/src/model/Model.cpp +++ b/openstudiocore/src/model/Model.cpp @@ -324,9 +324,17 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_CONSTRUCTOR(ElectricLoadCenterInverterSimple); REGISTER_CONSTRUCTOR(ElectricLoadCenterStorageSimple); REGISTER_CONSTRUCTOR(EnergyManagementSystemActuator); + REGISTER_CONSTRUCTOR(EnergyManagementSystemConstructionIndexVariable); + REGISTER_CONSTRUCTOR(EnergyManagementSystemCurveOrTableIndexVariable); + REGISTER_CONSTRUCTOR(EnergyManagementSystemGlobalVariable); + REGISTER_CONSTRUCTOR(EnergyManagementSystemInternalVariable); + REGISTER_CONSTRUCTOR(EnergyManagementSystemMeteredOutputVariable); + REGISTER_CONSTRUCTOR(EnergyManagementSystemOutputVariable); REGISTER_CONSTRUCTOR(EnergyManagementSystemProgram); REGISTER_CONSTRUCTOR(EnergyManagementSystemProgramCallingManager); REGISTER_CONSTRUCTOR(EnergyManagementSystemSensor); + REGISTER_CONSTRUCTOR(EnergyManagementSystemSubroutine); + REGISTER_CONSTRUCTOR(EnergyManagementSystemTrendVariable); REGISTER_CONSTRUCTOR(EvaporativeCoolerDirectResearchSpecial); REGISTER_CONSTRUCTOR(EvaporativeCoolerIndirectResearchSpecial); REGISTER_CONSTRUCTOR(EvaporativeFluidCoolerSingleSpeed); @@ -738,9 +746,17 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_COPYCONSTRUCTORS(ElectricLoadCenterInverterSimple); REGISTER_COPYCONSTRUCTORS(ElectricLoadCenterStorageSimple); REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemActuator); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemConstructionIndexVariable); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemCurveOrTableIndexVariable); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemGlobalVariable); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemInternalVariable); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemMeteredOutputVariable); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemOutputVariable); REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemProgram); REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemProgramCallingManager); REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemSensor); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemSubroutine); + REGISTER_COPYCONSTRUCTORS(EnergyManagementSystemTrendVariable); REGISTER_COPYCONSTRUCTORS(EvaporativeCoolerDirectResearchSpecial); REGISTER_COPYCONSTRUCTORS(EvaporativeCoolerIndirectResearchSpecial); REGISTER_COPYCONSTRUCTORS(EvaporativeFluidCoolerSingleSpeed); diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index c532f206b69..09c8cfbc600 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -172,6 +172,14 @@ MODELOBJECT_TEMPLATES(GenericModelObject); MODELOBJECT_TEMPLATES(ModelObjectList); MODELOBJECT_TEMPLATES(EnergyManagementSystemSensor); MODELOBJECT_TEMPLATES(EnergyManagementSystemActuator); +MODELOBJECT_TEMPLATES(EnergyManagementSystemConstructionIndexVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemCurveOrTableIndexVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemGlobalVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemInternalVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemMeteredOutputVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemOutputVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemTrendVariable); +MODELOBJECT_TEMPLATES(EnergyManagementSystemSubroutine); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); @@ -202,6 +210,14 @@ SWIG_MODELOBJECT(GenericModelObject, 0); SWIG_MODELOBJECT(ModelObjectList, 1); SWIG_MODELOBJECT(EnergyManagementSystemSensor, 1); SWIG_MODELOBJECT(EnergyManagementSystemActuator, 1); +SWIG_MODELOBJECT(EnergyManagementSystemConstructionIndexVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemCurveOrTableIndexVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemGlobalVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemInternalVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemMeteredOutputVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemOutputVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemTrendVariable, 1); +SWIG_MODELOBJECT(EnergyManagementSystemSubroutine, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); From 55595ec9396e6dc6f831c60ce19b4c8e2121a4a7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 24 Aug 2016 21:56:28 -0600 Subject: [PATCH 072/159] fix return types to something that compiles --- ...gyManagementSystemConstructionIndexVariable.cpp | 14 +++++++------- ...gyManagementSystemConstructionIndexVariable.hpp | 4 ++-- ...agementSystemConstructionIndexVariable_Impl.hpp | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp index 3b8627577f9..186b017bf77 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -68,21 +68,21 @@ namespace detail { return EnergyManagementSystemConstructionIndexVariable::iddObjectType(); } - Construction EnergyManagementSystemConstructionIndexVariable_Impl::constructionObject() const { - boost::optional value = optionalConstructionObject(); + ModelObject EnergyManagementSystemConstructionIndexVariable_Impl::constructionObject() const { + boost::optional value = optionalConstructionObject(); if (!value) { LOG_AND_THROW(briefDescription() << " does not have an Construction Object attached."); } return value.get(); } - bool EnergyManagementSystemConstructionIndexVariable_Impl::setConstructionObject(const Construction& construction) { + bool EnergyManagementSystemConstructionIndexVariable_Impl::setConstructionObject(const ModelObject& construction) { bool result = setPointer(OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName, construction.handle()); return result; } - boost::optional EnergyManagementSystemConstructionIndexVariable_Impl::optionalConstructionObject() const { - return getObject().getModelObjectTarget(OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); + boost::optional EnergyManagementSystemConstructionIndexVariable_Impl::optionalConstructionObject() const { + return getObject().getModelObjectTarget(OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); } } // detail @@ -103,11 +103,11 @@ IddObjectType EnergyManagementSystemConstructionIndexVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable); } -Construction EnergyManagementSystemConstructionIndexVariable::constructionObject() const { +ModelObject EnergyManagementSystemConstructionIndexVariable::constructionObject() const { return getImpl()->constructionObject(); } -bool EnergyManagementSystemConstructionIndexVariable::setConstructionObject(const Construction& construction) { +bool EnergyManagementSystemConstructionIndexVariable::setConstructionObject(const ModelObject& construction) { return getImpl()->setConstructionObject(construction); } diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp index e6a0980f064..4fb3f54daee 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp @@ -53,14 +53,14 @@ class MODEL_API EnergyManagementSystemConstructionIndexVariable : public ModelOb //@{ // TODO: Check return type. From object lists, some candidates are: Construction. - Construction constructionObject() const; + ModelObject constructionObject() const; //@} /** @name Setters */ //@{ // TODO: Check argument type. From object lists, some candidates are: Construction. - bool setConstructionObject(const Construction& construction); + bool setConstructionObject(const ModelObject& construction); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp index b50790ff072..f6b5184a12e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp @@ -64,14 +64,14 @@ namespace detail { //@{ // TODO: Check return type. From object lists, some candidates are: Construction. - Construction constructionObject() const; + ModelObject constructionObject() const; //@} /** @name Setters */ //@{ // TODO: Check argument type. From object lists, some candidates are: Construction. - bool setConstructionObject(const Construction& construction); + bool setConstructionObject(const ModelObject& construction); //@} /** @name Other */ @@ -86,7 +86,7 @@ namespace detail { // Optional getters for use by methods like children() so can remove() if the constructor fails. // There are other ways for the public versions of these getters to fail--perhaps all required // objects should be returned as boost::optionals - boost::optional optionalConstructionObject() const; + boost::optional optionalConstructionObject() const; }; } // detail From b92a55e8ec03e05218ca99cdb281775eff12ae74 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 25 Aug 2016 15:10:02 -0600 Subject: [PATCH 073/159] add EMS globalVariable to model --- .../EnergyManagementSystemGlobalVariable.cpp | 64 ++++++++++++++++++- .../EnergyManagementSystemGlobalVariable.hpp | 6 +- ...rgyManagementSystemGlobalVariable_Impl.hpp | 6 +- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp index a2db180cb90..4ab348c3387 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -25,6 +25,8 @@ #include "../utilities/core/Assert.hpp" +#include "ModelExtensibleGroup.hpp" + namespace openstudio { namespace model { @@ -64,20 +66,78 @@ namespace detail { return EnergyManagementSystemGlobalVariable::iddObjectType(); } + bool EnergyManagementSystemGlobalVariable_Impl::addVariable(const std::string& variable) { + //set global variable + bool result = false; + + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, variable); + + return result; + } + + bool EnergyManagementSystemGlobalVariable_Impl::removeVariable(const std::string& variable) { + //remove global variable + bool result = false; + + auto groups = extensibleGroups(); + unsigned sizeOfGroup = numExtensibleGroups(); + int i = 0; + for (auto group = groups.begin(); group != groups.end(); ++group) { + if (group->getString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, true) == variable) { + eraseExtensibleGroup(i); + i++; + result = true; + } + } + return result; + } + + std::vector EnergyManagementSystemGlobalVariable_Impl::getVariables() const { + //return vector of global variables + std::vector result; + auto groups = extensibleGroups(); + + for (auto group = groups.begin(); group != groups.end(); ++group) { + const auto & variable = group->getString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, true); + OS_ASSERT(variable); + result.push_back(variable.get()); + } + return result; + } + + void EnergyManagementSystemGlobalVariable_Impl::eraseVariables() { + //erase all Variables in this global variable object + clearExtensibleGroups(); + } } // detail EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const Model& model) : ModelObject(EnergyManagementSystemGlobalVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. } IddObjectType EnergyManagementSystemGlobalVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); } +bool EnergyManagementSystemGlobalVariable::addVariable(const std::string& variable) { + return getImpl()->addVariable(variable); +} + +bool EnergyManagementSystemGlobalVariable::removeVariable(const std::string& variable) { + return getImpl()->removeVariable(variable); +} + +std::vector EnergyManagementSystemGlobalVariable::getVariables() const { + return getImpl()->getVariables(); +} + +void EnergyManagementSystemGlobalVariable::eraseVariables() { + getImpl()->eraseVariables(); +} + /// @cond EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp index 4a35f1571ab..b76a2d515c9 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -49,13 +49,15 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. + std::vector getVariables() const; //@} /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. + bool addVariable(const std::string& variable); + bool removeVariable(const std::string& variable); + void eraseVariables(); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp index fc271ad3e4f..c0239f21c8b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp @@ -60,13 +60,15 @@ namespace detail { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. + std::vector getVariables() const; //@} /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. + bool addVariable(const std::string& variable); + bool removeVariable(const std::string& variable); + void eraseVariables(); //@} /** @name Other */ From c0f03e9290584f1826aad20d93ffe34c99d952c1 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 25 Aug 2016 16:21:36 -0600 Subject: [PATCH 074/159] =?UTF-8?q?addressing=20=E2=80=9Csigned/unsigned?= =?UTF-8?q?=20mismatch=E2=80=9D=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/EnergyManagementSystemProgram.cpp | 48 +++++++++---------- ...yManagementSystemProgramCallingManager.cpp | 10 ++-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 6a9a059360f..de2007882ab 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -109,15 +109,15 @@ namespace detail { //add program lines to body std::vector ok(body_minus_nl.size(), false); - for (int i = 0; i < body_minus_nl.size(); i++) { + for (size_t i = 0; i < body_minus_nl.size(); i++) { WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl[i] + '\n'); + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl.at(i) + '\n'); ok.push_back(result); } //check if all the programs set true result = true; - for (int i = 0; i ok(lines.size(), false); - for (int i = 0; i < lines.size(); i++) { + for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line - result = addLine(lines[i]); + result = addLine(lines.at(i)); ok.push_back(result); } //check if all the programs set true result = true; - for (int i = 0; i> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings - for (int i = 0; i < body.get().size(); i++) { + for (size_t i = 0; i < body.get().size(); i++) { //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get()[i], ' '); - for (int j = 0; j < results.size(); j++) { - if (results[j].size() == 38) { + std::vector results = splitString(body.get().at(i), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { //remove {} from uid string - std::string possible_uid = results[j].substr(1, results[j].size() - 2); + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); //std::vector handle = &uid; @@ -224,9 +224,9 @@ namespace detail { //m.getModelObjects(&uid); std::vector modelObjects = m.getModelObjects(); if (modelObjects.size() > 0) { - for (int k = 0; k < modelObjects.size(); k++) { - if (modelObjects[k].handle() == uid) { - result.push_back(modelObjects[k]); + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + result.push_back(modelObjects.at(k)); }; } }; @@ -244,16 +244,16 @@ namespace detail { boost::optional> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings - for (int i = 0; i < body.get().size(); i++) { + for (size_t i = 0; i < body.get().size(); i++) { int found = 0; //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get()[i], ' '); - for (int j = 0; j < results.size(); j++) { - if (results[j].size() == 38) { + std::vector results = splitString(body.get().at(i), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { //possible uid so set found to 1 found = 1; //remove {} from uid string - std::string possible_uid = results[j].substr(1, results[j].size() - 2); + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); //std::vector handle = &uid; @@ -262,8 +262,8 @@ namespace detail { //m.getModelObjects(&uid); std::vector modelObjects = m.getModelObjects(); if (modelObjects.size() > 0) { - for (int k = 0; k < modelObjects.size(); k++) { - if (modelObjects[k].handle() == uid) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { found++; }; } @@ -272,7 +272,7 @@ namespace detail { } //possible uid not found in model if (found == 1) { - result.push_back(body.get()[i]); + result.push_back(body.get().at(i)); }; } } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 4a01200ad10..73bd05d1789 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -170,8 +170,8 @@ namespace detail { } //check if all the programs set true result = true; - for (int i = 0; inullPrograms(); if (!nullProgs.empty()) { - for (int i = 0; i < nullProgs.size(); i++) { - result = this->eraseProgram(i); + int j = 0; + for (size_t i = 0; i < nullProgs.size(); i++) { + result = this->eraseProgram(j); + j++; }; }; return result; From 8bdd00e27f308c88f03b9811da21730dec57d26f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 25 Aug 2016 17:45:26 -0600 Subject: [PATCH 075/159] add EMS subroutine to model --- .../EnergyManagementSystemSubroutine.cpp | 246 ++++++++++++++++++ .../EnergyManagementSystemSubroutine.hpp | 16 +- .../EnergyManagementSystemSubroutine_Impl.hpp | 16 +- 3 files changed, 274 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 922da54700f..3eaf853b807 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -25,6 +25,13 @@ #include "../utilities/core/Assert.hpp" +#include "ModelExtensibleGroup.hpp" +#include "Model.hpp" + +#include "../utilities/core/String.hpp" +#include "../utilities/core/StringHelpers.hpp" +#include "../utilities/core/UUID.hpp" + namespace openstudio { namespace model { @@ -64,6 +71,212 @@ namespace detail { return EnergyManagementSystemSubroutine::iddObjectType(); } + boost::optional EnergyManagementSystemSubroutine_Impl::body() const { + //return program body as string + + // loop through extensible groups and add ProgramLine to body string. + std::string body; + auto groups = extensibleGroups(); + for (auto group = groups.begin(); group != groups.end(); ++group) { + const auto & line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); + OS_ASSERT(line); + body += line.get(); + } + return body; + } + + bool EnergyManagementSystemSubroutine_Impl::setBody(const std::string& body) { + //set body of program to input string + bool result = false; + //if body string empty then return false + if (body.empty()) { + return false; + }; + + //clobber existing body + this->eraseBody(); + + // remove '\r' from the body string + std::string body_minus_r = body; + std::string::size_type pos = 0; // Must initialize + while ((pos = body_minus_r.find("\r", pos)) != std::string::npos) { + body_minus_r.erase(pos, 1); + } + + //split the body string on newline characters and insert program line for each string line + std::vector body_minus_nl = splitString(body_minus_r, '\n'); + + //add program lines to body + std::vector ok(body_minus_nl.size(), false); + for (size_t i = 0; i < body_minus_nl.size(); i++) { + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, body_minus_nl.at(i) + '\n'); + ok.push_back(result); + } + //check if all the programs set true + result = true; + for (size_t i = 0; i > result; + result = clearExtensibleGroups(); + // if result is not empty, then the group was cleared out since the old values were returned + if (!result.empty()) { + results = true; + }; + return results; + } + + bool EnergyManagementSystemSubroutine_Impl::addLine(const std::string& line) { + //add line to end of program body + bool result = true; + + // remove '\r' from the line string + std::string line_rn = line; + std::string::size_type pos = 0; // Must initialize + while ((pos = line_rn.find("\r", pos)) != std::string::npos) { + line_rn.erase(pos, 1); + } + // remove '\n' since we add it back in below + pos = 0; + while ((pos = line_rn.find("\n", pos)) != std::string::npos) { + line_rn.erase(pos, 1); + } + + WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); + result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, line_rn + '\n'); + return result; + } + + boost::optional> EnergyManagementSystemSubroutine_Impl::lines() const { + //return vector of lines from body + std::vector result; + + // loop through extensible groups and add ProgramLine to vector result. + auto groups = extensibleGroups(); + + for (auto group = groups.begin(); group != groups.end(); ++group) { + const auto & line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); + OS_ASSERT(line); + result.push_back(line.get()); + } + return result; + } + + bool EnergyManagementSystemSubroutine_Impl::setLines(const std::vector& lines) { + //set body of program to input vector of strings + bool result = false; + std::string temp; + + //if body string empty then return false + if (lines.empty()) { + return false; + }; + + //clobber existing body + this->eraseBody(); + + //add program lines to body + std::vector ok(lines.size(), false); + for (size_t i = 0; i < lines.size(); i++) { + //use method addLine to add each line + result = addLine(lines.at(i)); + ok.push_back(result); + } + //check if all the programs set true + result = true; + for (size_t i = 0; i EnergyManagementSystemSubroutine_Impl::referencedObjects() const { + //return vector of model objects that are referenced in program + std::vector result; + + boost::optional> body = this->lines(); + if (body.is_initialized()) { + //assume body is a vector of strings + for (size_t i = 0; i < body.get().size(); i++) { + //split string on whitespaces to isolate possible uids + std::vector results = splitString(body.get().at(i), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { + //remove {} from uid string + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //std::vector handle = &uid; + Model m = this->model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + result.push_back(modelObjects.at(k)); + }; + } + }; + } + } + } + } + return result; + } + + std::vector EnergyManagementSystemSubroutine_Impl::invalidReferencedObjects() const { + //return vector of body lines that contain missing uid strings for invalid referenced objects + std::vector result; + + boost::optional> body = this->lines(); + if (body.is_initialized()) { + //assume body is a vector of strings + for (size_t i = 0; i < body.get().size(); i++) { + int found = 0; + //split string on whitespaces to isolate possible uids + std::vector results = splitString(body.get().at(i), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { + //possible uid so set found to 1 + found = 1; + //remove {} from uid string + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //std::vector handle = &uid; + Model m = this->model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + found++; + }; + } + }; + } + } + //possible uid not found in model + if (found == 1) { + result.push_back(body.get().at(i)); + }; + } + } + return result; + } } // detail EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(const Model& model) @@ -78,6 +291,39 @@ IddObjectType EnergyManagementSystemSubroutine::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Subroutine); } + +boost::optional EnergyManagementSystemSubroutine::body() const { + return getImpl()->body(); +} + +bool EnergyManagementSystemSubroutine::setBody(const std::string& body) { + return getImpl()->setBody(body); +} + +bool EnergyManagementSystemSubroutine::eraseBody() { + return getImpl()->eraseBody(); +} + +bool EnergyManagementSystemSubroutine::addLine(const std::string& line) { + return getImpl()->addLine(line); +} + +boost::optional> EnergyManagementSystemSubroutine::lines() const { + return getImpl()->lines(); +} + +bool EnergyManagementSystemSubroutine::setLines(const std::vector& lines) { + return getImpl()->setLines(lines); +} + +std::vector EnergyManagementSystemSubroutine::referencedObjects() const { + return getImpl()->referencedObjects(); +} + +std::vector EnergyManagementSystemSubroutine::invalidReferencedObjects() const { + return getImpl()->invalidReferencedObjects(); +} + /// @cond EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp index e26ebcba259..6723a721fe6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp @@ -49,13 +49,25 @@ class MODEL_API EnergyManagementSystemSubroutine : public ModelObject { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. + boost::optional body() const; + + boost::optional> lines() const; + + std::vector referencedObjects() const; + + std::vector invalidReferencedObjects() const; //@} /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. + bool setBody(const std::string& body); + + bool eraseBody(); + + bool addLine(const std::string& body); + + bool setLines(const std::vector& body); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp index 60e82880269..c205aa9079e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp @@ -60,13 +60,25 @@ namespace detail { /** @name Getters */ //@{ - // TODO: Handle this object's extensible fields. + boost::optional body() const; + + boost::optional> lines() const; + + std::vector referencedObjects() const; + + std::vector invalidReferencedObjects() const; //@} /** @name Setters */ //@{ - // TODO: Handle this object's extensible fields. + bool setBody(const std::string& body); + + bool eraseBody(); + + bool addLine(const std::string& body); + + bool setLines(const std::vector& body); //@} /** @name Other */ From 4550e1b6a17609218df6d28a92a03cbe5ac75f51 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 12:05:12 -0600 Subject: [PATCH 076/159] outputVariable in model TrendVariable in model --- .../EnergyManagementSystemGlobalVariable.hpp | 2 ++ ...rgyManagementSystemGlobalVariable_Impl.hpp | 2 ++ .../EnergyManagementSystemOutputVariable.cpp | 32 +++++++------------ .../EnergyManagementSystemOutputVariable.hpp | 6 ++-- ...rgyManagementSystemOutputVariable_Impl.hpp | 6 ++-- .../EnergyManagementSystemTrendVariable.cpp | 13 +++----- .../EnergyManagementSystemTrendVariable.hpp | 2 +- ...ergyManagementSystemTrendVariable_Impl.hpp | 2 +- openstudiocore/src/model/ModelCore.i | 4 +-- 9 files changed, 30 insertions(+), 39 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp index b76a2d515c9..70eb7e3e60e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -56,7 +56,9 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { //@{ bool addVariable(const std::string& variable); + bool removeVariable(const std::string& variable); + void eraseVariables(); //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp index c0239f21c8b..e3a857bef4a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp @@ -67,7 +67,9 @@ namespace detail { //@{ bool addVariable(const std::string& variable); + bool removeVariable(const std::string& variable); + void eraseVariables(); //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 1a41ba56ce6..76c881a9e7b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -91,9 +91,9 @@ namespace detail { return getString(OS_EnergyManagementSystem_OutputVariableFields::Units,true); } - void EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, eMSVariableName); - OS_ASSERT(result); + return result; } bool EnergyManagementSystemOutputVariable_Impl::setTypeofDatainVariable(const std::string& typeofDatainVariable) { @@ -106,9 +106,9 @@ namespace detail { return result; } - void EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, eMSProgramorSubroutineName); - OS_ASSERT(result); + return result; } void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { @@ -116,9 +116,9 @@ namespace detail { OS_ASSERT(result); } - void EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { + bool EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, units); - OS_ASSERT(result); + return result; } void EnergyManagementSystemOutputVariable_Impl::resetUnits() { @@ -132,14 +132,6 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // setEMSVariableName(); - bool ok = true; - // ok = setTypeofDatainVariable(); - OS_ASSERT(ok); - // ok = setUpdateFrequency(); - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { @@ -176,8 +168,8 @@ boost::optional EnergyManagementSystemOutputVariable::units() const return getImpl()->units(); } -void EnergyManagementSystemOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { - getImpl()->setEMSVariableName(eMSVariableName); +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + return getImpl()->setEMSVariableName(eMSVariableName); } bool EnergyManagementSystemOutputVariable::setTypeofDatainVariable(const std::string& typeofDatainVariable) { @@ -188,16 +180,16 @@ bool EnergyManagementSystemOutputVariable::setUpdateFrequency(const std::string& return getImpl()->setUpdateFrequency(updateFrequency); } -void EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { - getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); +bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { + return getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); } void EnergyManagementSystemOutputVariable::resetEMSProgramorSubroutineName() { getImpl()->resetEMSProgramorSubroutineName(); } -void EnergyManagementSystemOutputVariable::setUnits(const std::string& units) { - getImpl()->setUnits(units); +bool EnergyManagementSystemOutputVariable::setUnits(const std::string& units) { + return getImpl()->setUnits(units); } void EnergyManagementSystemOutputVariable::resetUnits() { diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index 03923623804..af6809050ef 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -67,17 +67,17 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setTypeofDatainVariable(const std::string& typeofDatainVariable); bool setUpdateFrequency(const std::string& updateFrequency); - void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); void resetEMSProgramorSubroutineName(); - void setUnits(const std::string& units); + bool setUnits(const std::string& units); void resetUnits(); diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp index 7fc4ac431d5..51abbe4fb77 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp @@ -74,17 +74,17 @@ namespace detail { /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setTypeofDatainVariable(const std::string& typeofDatainVariable); bool setUpdateFrequency(const std::string& updateFrequency); - void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); void resetEMSProgramorSubroutineName(); - void setUnits(const std::string& units); + bool setUnits(const std::string& units); void resetUnits(); diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index bb3012f0f52..e5f28c0bf88 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -76,9 +76,10 @@ namespace detail { return value.get(); } - void EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, eMSVariableName); OS_ASSERT(result); + return result; } bool EnergyManagementSystemTrendVariable_Impl::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { @@ -92,12 +93,6 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // setEMSVariableName(); - bool ok = true; - // ok = setNumberofTimestepstobeLogged(); - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemTrendVariable::iddObjectType() { @@ -112,8 +107,8 @@ int EnergyManagementSystemTrendVariable::numberofTimestepstobeLogged() const { return getImpl()->numberofTimestepstobeLogged(); } -void EnergyManagementSystemTrendVariable::setEMSVariableName(const std::string& eMSVariableName) { - getImpl()->setEMSVariableName(eMSVariableName); +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const std::string& eMSVariableName) { + return getImpl()->setEMSVariableName(eMSVariableName); } bool EnergyManagementSystemTrendVariable::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp index ed796225fc2..828fa80b739 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -57,7 +57,7 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp index 060ddd0da16..0983c91bbda 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp @@ -68,7 +68,7 @@ namespace detail { /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index 09c8cfbc600..5cfbba977d1 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -177,11 +177,11 @@ MODELOBJECT_TEMPLATES(EnergyManagementSystemCurveOrTableIndexVariable); MODELOBJECT_TEMPLATES(EnergyManagementSystemGlobalVariable); MODELOBJECT_TEMPLATES(EnergyManagementSystemInternalVariable); MODELOBJECT_TEMPLATES(EnergyManagementSystemMeteredOutputVariable); -MODELOBJECT_TEMPLATES(EnergyManagementSystemOutputVariable); MODELOBJECT_TEMPLATES(EnergyManagementSystemTrendVariable); MODELOBJECT_TEMPLATES(EnergyManagementSystemSubroutine); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); +MODELOBJECT_TEMPLATES(EnergyManagementSystemOutputVariable); SWIG_MODELOBJECT(ModelObject, 0); SWIG_MODELEXTENSIBLEGROUP(ModelExtensibleGroup); @@ -215,10 +215,10 @@ SWIG_MODELOBJECT(EnergyManagementSystemCurveOrTableIndexVariable, 1); SWIG_MODELOBJECT(EnergyManagementSystemGlobalVariable, 1); SWIG_MODELOBJECT(EnergyManagementSystemInternalVariable, 1); SWIG_MODELOBJECT(EnergyManagementSystemMeteredOutputVariable, 1); -SWIG_MODELOBJECT(EnergyManagementSystemOutputVariable, 1); SWIG_MODELOBJECT(EnergyManagementSystemTrendVariable, 1); SWIG_MODELOBJECT(EnergyManagementSystemSubroutine, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); +SWIG_MODELOBJECT(EnergyManagementSystemOutputVariable, 1); #endif //MODEL_CORE_I From cf759a30d50abd0aeff11aaa5e2e1296ef3c1b2c Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 14:13:01 -0600 Subject: [PATCH 077/159] output:EnergyManagementSystem to model --- developer/ruby/MakeModelObjects.rb | 17 +- openstudiocore/resources/model/OpenStudio.idd | 29 +++ openstudiocore/src/model/CMakeLists.txt | 3 + .../src/model/ConcreteModelObjects.hpp | 2 + openstudiocore/src/model/Model.cpp | 2 + openstudiocore/src/model/ModelCore.i | 2 + .../model/OutputEnergyManagementSystem.cpp | 209 ++++++++++++++++++ .../model/OutputEnergyManagementSystem.hpp | 116 ++++++++++ .../OutputEnergyManagementSystem_Impl.hpp | 107 +++++++++ 9 files changed, 479 insertions(+), 8 deletions(-) create mode 100644 openstudiocore/src/model/OutputEnergyManagementSystem.cpp create mode 100644 openstudiocore/src/model/OutputEnergyManagementSystem.hpp create mode 100644 openstudiocore/src/model/OutputEnergyManagementSystem_Impl.hpp diff --git a/developer/ruby/MakeModelObjects.rb b/developer/ruby/MakeModelObjects.rb index a75edfccae3..aaaa093b503 100644 --- a/developer/ruby/MakeModelObjects.rb +++ b/developer/ruby/MakeModelObjects.rb @@ -88,14 +88,15 @@ # objects << ["OS:EnergyManagementSystem:Actuator", "EnergyManagementSystemActuator", "ModelObject"] # objects << ["OS:EnergyManagementSystem:ProgramCallingManager", "EnergyManagementSystemProgramCallingManager", "ModelObject"] # objects << ["OS:EnergyManagementSystem:Program", "EnergyManagementSystemProgram", "ModelObject"] -objects << ["OS:EnergyManagementSystem:GlobalVariable", "EnergyManagementSystemGlobalVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:Subroutine", "EnergyManagementSystemSubroutine", "ModelObject"] -objects << ["OS:EnergyManagementSystem:OutputVariable", "EnergyManagementSystemOutputVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:MeteredOutputVariable", "EnergyManagementSystemMeteredOutputVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:TrendVariable", "EnergyManagementSystemTrendVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:InternalVariable", "EnergyManagementSystemInternalVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:CurveOrTableIndexVariable", "EnergyManagementSystemCurveOrTableIndexVariable", "ModelObject"] -objects << ["OS:EnergyManagementSystem:ConstructionIndexVariable", "EnergyManagementSystemConstructionIndexVariable", "ModelObject"] +# objects << ["OS:EnergyManagementSystem:GlobalVariable", "EnergyManagementSystemGlobalVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:Subroutine", "EnergyManagementSystemSubroutine", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:OutputVariable", "EnergyManagementSystemOutputVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:MeteredOutputVariable", "EnergyManagementSystemMeteredOutputVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:TrendVariable", "EnergyManagementSystemTrendVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:InternalVariable", "EnergyManagementSystemInternalVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:CurveOrTableIndexVariable", "EnergyManagementSystemCurveOrTableIndexVariable", "ModelObject"] +#objects << ["OS:EnergyManagementSystem:ConstructionIndexVariable", "EnergyManagementSystemConstructionIndexVariable", "ModelObject"] +objects << ["OS:Output:EnergyManagementSystem", "OutputEnergyManagementSystem", "ModelObject"] includePath = nil if /mswin/.match(RUBY_PLATFORM) || /mingw/.match(RUBY_PLATFORM) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index fdce9b9b2da..20edad70f30 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26367,6 +26367,35 @@ OS:Meter:CustomDecrement, \begin-extensible A6; \field Output Variable or Meter Name +OS:Output:EnergyManagementSystem, + \memo This object is used to control the output produced by the Energy Management System + \unique-object + \min-fields 2 + A1, \field Handle + \type handle + \required-field + A2, \field Name + \required-field + \type alpha + A3, \field Actuator Availability Dictionary Reporting + \type choice + \key None + \key NotByUniqueKeyNames + \key Verbose + \default None + A4, \field Internal Variable Availability Dictionary Reporting + \type choice + \key None + \key NotByUniqueKeyNames + \key Verbose + \default None + A5; \field EMS Runtime Language Debug Output Level + \type choice + \key None + \key ErrorsOnly + \key Verbose + \default None + \group Energy Management System (EMS) OS:EnergyManagementSystem:Sensor, diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index d1de996c55d..f566b7155fd 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -709,6 +709,9 @@ set(${target_name}_src OutputControlReportingTolerances.hpp OutputControlReportingTolerances_Impl.hpp OutputControlReportingTolerances.cpp + OutputEnergyManagementSystem.cpp + OutputEnergyManagementSystem.hpp + OutputEnergyManagementSystem_Impl.hpp OutputMeter.hpp OutputMeter_Impl.hpp OutputMeter.cpp diff --git a/openstudiocore/src/model/ConcreteModelObjects.hpp b/openstudiocore/src/model/ConcreteModelObjects.hpp index 89c407c6e9e..14bafcff549 100644 --- a/openstudiocore/src/model/ConcreteModelObjects.hpp +++ b/openstudiocore/src/model/ConcreteModelObjects.hpp @@ -230,6 +230,7 @@ #include "OtherEquipment.hpp" #include "OtherEquipmentDefinition.hpp" #include "OutputControlReportingTolerances.hpp" +#include "OutputEnergyManagementSystem.hpp" #include "OutputMeter.hpp" #include "OutputVariable.hpp" #include "OutsideSurfaceConvectionAlgorithm.hpp" @@ -620,6 +621,7 @@ #include "OtherEquipment_Impl.hpp" #include "OtherEquipmentDefinition_Impl.hpp" #include "OutputControlReportingTolerances_Impl.hpp" +#include "OutputEnergyManagementSystem_Impl.hpp" #include "OutputMeter_Impl.hpp" #include "OutputVariable_Impl.hpp" #include "OutsideSurfaceConvectionAlgorithm_Impl.hpp" diff --git a/openstudiocore/src/model/Model.cpp b/openstudiocore/src/model/Model.cpp index 3af3e15f0aa..89df6fcfb52 100644 --- a/openstudiocore/src/model/Model.cpp +++ b/openstudiocore/src/model/Model.cpp @@ -396,6 +396,7 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_CONSTRUCTOR(OtherEquipment); REGISTER_CONSTRUCTOR(OtherEquipmentDefinition); REGISTER_CONSTRUCTOR(OutputControlReportingTolerances); + REGISTER_CONSTRUCTOR(OutputEnergyManagementSystem); REGISTER_CONSTRUCTOR(OutputMeter); REGISTER_CONSTRUCTOR(OutputVariable); REGISTER_CONSTRUCTOR(OutsideSurfaceConvectionAlgorithm); @@ -818,6 +819,7 @@ if (_className::iddObjectType() == typeToCreate) { \ REGISTER_COPYCONSTRUCTORS(OtherEquipment); REGISTER_COPYCONSTRUCTORS(OtherEquipmentDefinition); REGISTER_COPYCONSTRUCTORS(OutputControlReportingTolerances); + REGISTER_COPYCONSTRUCTORS(OutputEnergyManagementSystem); REGISTER_COPYCONSTRUCTORS(OutputMeter); REGISTER_COPYCONSTRUCTORS(OutputVariable); REGISTER_COPYCONSTRUCTORS(OutsideSurfaceConvectionAlgorithm); diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index 5cfbba977d1..92614c1e199 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -182,6 +182,7 @@ MODELOBJECT_TEMPLATES(EnergyManagementSystemSubroutine); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); MODELOBJECT_TEMPLATES(EnergyManagementSystemOutputVariable); +MODELOBJECT_TEMPLATES(OutputEnergyManagementSystem); SWIG_MODELOBJECT(ModelObject, 0); SWIG_MODELEXTENSIBLEGROUP(ModelExtensibleGroup); @@ -220,5 +221,6 @@ SWIG_MODELOBJECT(EnergyManagementSystemSubroutine, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); SWIG_MODELOBJECT(EnergyManagementSystemOutputVariable, 1); +SWIG_MODELOBJECT(OutputEnergyManagementSystem, 1); #endif //MODEL_CORE_I diff --git a/openstudiocore/src/model/OutputEnergyManagementSystem.cpp b/openstudiocore/src/model/OutputEnergyManagementSystem.cpp new file mode 100644 index 00000000000..241b94daa96 --- /dev/null +++ b/openstudiocore/src/model/OutputEnergyManagementSystem.cpp @@ -0,0 +1,209 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "OutputEnergyManagementSystem.hpp" +#include "OutputEnergyManagementSystem_Impl.hpp" + +#include +#include +#include + +#include "../utilities/core/Assert.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + OutputEnergyManagementSystem_Impl::OutputEnergyManagementSystem_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(idfObject,model,keepHandle) + { + OS_ASSERT(idfObject.iddObject().type() == OutputEnergyManagementSystem::iddObjectType()); + } + + OutputEnergyManagementSystem_Impl::OutputEnergyManagementSystem_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + { + OS_ASSERT(other.iddObject().type() == OutputEnergyManagementSystem::iddObjectType()); + } + + OutputEnergyManagementSystem_Impl::OutputEnergyManagementSystem_Impl(const OutputEnergyManagementSystem_Impl& other, + Model_Impl* model, + bool keepHandle) + : ModelObject_Impl(other,model,keepHandle) + {} + + const std::vector& OutputEnergyManagementSystem_Impl::outputVariableNames() const + { + static std::vector result; + if (result.empty()){ + } + return result; + } + + IddObjectType OutputEnergyManagementSystem_Impl::iddObjectType() const { + return OutputEnergyManagementSystem::iddObjectType(); + } + + std::string OutputEnergyManagementSystem_Impl::actuatorAvailabilityDictionaryReporting() const { + boost::optional value = getString(OS_Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting,true); + OS_ASSERT(value); + return value.get(); + } + + bool OutputEnergyManagementSystem_Impl::isActuatorAvailabilityDictionaryReportingDefaulted() const { + return isEmpty(OS_Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting); + } + + std::string OutputEnergyManagementSystem_Impl::internalVariableAvailabilityDictionaryReporting() const { + boost::optional value = getString(OS_Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting,true); + OS_ASSERT(value); + return value.get(); + } + + bool OutputEnergyManagementSystem_Impl::isInternalVariableAvailabilityDictionaryReportingDefaulted() const { + return isEmpty(OS_Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting); + } + + std::string OutputEnergyManagementSystem_Impl::eMSRuntimeLanguageDebugOutputLevel() const { + boost::optional value = getString(OS_Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel,true); + OS_ASSERT(value); + return value.get(); + } + + bool OutputEnergyManagementSystem_Impl::isEMSRuntimeLanguageDebugOutputLevelDefaulted() const { + return isEmpty(OS_Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel); + } + + bool OutputEnergyManagementSystem_Impl::setActuatorAvailabilityDictionaryReporting(const std::string& actuatorAvailabilityDictionaryReporting) { + bool result = setString(OS_Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting, actuatorAvailabilityDictionaryReporting); + return result; + } + + void OutputEnergyManagementSystem_Impl::resetActuatorAvailabilityDictionaryReporting() { + bool result = setString(OS_Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting, ""); + OS_ASSERT(result); + } + + bool OutputEnergyManagementSystem_Impl::setInternalVariableAvailabilityDictionaryReporting(const std::string& internalVariableAvailabilityDictionaryReporting) { + bool result = setString(OS_Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting, internalVariableAvailabilityDictionaryReporting); + return result; + } + + void OutputEnergyManagementSystem_Impl::resetInternalVariableAvailabilityDictionaryReporting() { + bool result = setString(OS_Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting, ""); + OS_ASSERT(result); + } + + bool OutputEnergyManagementSystem_Impl::setEMSRuntimeLanguageDebugOutputLevel(const std::string& eMSRuntimeLanguageDebugOutputLevel) { + bool result = setString(OS_Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel, eMSRuntimeLanguageDebugOutputLevel); + return result; + } + + void OutputEnergyManagementSystem_Impl::resetEMSRuntimeLanguageDebugOutputLevel() { + bool result = setString(OS_Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel, ""); + OS_ASSERT(result); + } + +} // detail + +IddObjectType OutputEnergyManagementSystem::iddObjectType() { + return IddObjectType(IddObjectType::OS_Output_EnergyManagementSystem); +} + +std::vector OutputEnergyManagementSystem::actuatorAvailabilityDictionaryReportingValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting); +} + +std::vector OutputEnergyManagementSystem::internalVariableAvailabilityDictionaryReportingValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting); +} + +std::vector OutputEnergyManagementSystem::eMSRuntimeLanguageDebugOutputLevelValues() { + return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), + OS_Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel); +} + +std::string OutputEnergyManagementSystem::actuatorAvailabilityDictionaryReporting() const { + return getImpl()->actuatorAvailabilityDictionaryReporting(); +} + +bool OutputEnergyManagementSystem::isActuatorAvailabilityDictionaryReportingDefaulted() const { + return getImpl()->isActuatorAvailabilityDictionaryReportingDefaulted(); +} + +std::string OutputEnergyManagementSystem::internalVariableAvailabilityDictionaryReporting() const { + return getImpl()->internalVariableAvailabilityDictionaryReporting(); +} + +bool OutputEnergyManagementSystem::isInternalVariableAvailabilityDictionaryReportingDefaulted() const { + return getImpl()->isInternalVariableAvailabilityDictionaryReportingDefaulted(); +} + +std::string OutputEnergyManagementSystem::eMSRuntimeLanguageDebugOutputLevel() const { + return getImpl()->eMSRuntimeLanguageDebugOutputLevel(); +} + +bool OutputEnergyManagementSystem::isEMSRuntimeLanguageDebugOutputLevelDefaulted() const { + return getImpl()->isEMSRuntimeLanguageDebugOutputLevelDefaulted(); +} + +bool OutputEnergyManagementSystem::setActuatorAvailabilityDictionaryReporting(const std::string& actuatorAvailabilityDictionaryReporting) { + return getImpl()->setActuatorAvailabilityDictionaryReporting(actuatorAvailabilityDictionaryReporting); +} + +void OutputEnergyManagementSystem::resetActuatorAvailabilityDictionaryReporting() { + getImpl()->resetActuatorAvailabilityDictionaryReporting(); +} + +bool OutputEnergyManagementSystem::setInternalVariableAvailabilityDictionaryReporting(const std::string& internalVariableAvailabilityDictionaryReporting) { + return getImpl()->setInternalVariableAvailabilityDictionaryReporting(internalVariableAvailabilityDictionaryReporting); +} + +void OutputEnergyManagementSystem::resetInternalVariableAvailabilityDictionaryReporting() { + getImpl()->resetInternalVariableAvailabilityDictionaryReporting(); +} + +bool OutputEnergyManagementSystem::setEMSRuntimeLanguageDebugOutputLevel(const std::string& eMSRuntimeLanguageDebugOutputLevel) { + return getImpl()->setEMSRuntimeLanguageDebugOutputLevel(eMSRuntimeLanguageDebugOutputLevel); +} + +void OutputEnergyManagementSystem::resetEMSRuntimeLanguageDebugOutputLevel() { + getImpl()->resetEMSRuntimeLanguageDebugOutputLevel(); +} + +/// @cond +OutputEnergyManagementSystem::OutputEnergyManagementSystem(std::shared_ptr impl) + : ModelObject(impl) +{} +OutputEnergyManagementSystem::OutputEnergyManagementSystem(Model& model) + : ModelObject(OutputEnergyManagementSystem::iddObjectType(),model) +{} + +/// @endcond + +} // model +} // openstudio + diff --git a/openstudiocore/src/model/OutputEnergyManagementSystem.hpp b/openstudiocore/src/model/OutputEnergyManagementSystem.hpp new file mode 100644 index 00000000000..6f145a3ed14 --- /dev/null +++ b/openstudiocore/src/model/OutputEnergyManagementSystem.hpp @@ -0,0 +1,116 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_HPP +#define MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_HPP + +#include +#include "ModelObject.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + class OutputEnergyManagementSystem_Impl; + +} // detail + +/** OutputEnergyManagementSystem is a ModelObject that wraps the OpenStudio IDD object 'OS:Output:EnergyManagementSystem'. */ +class MODEL_API OutputEnergyManagementSystem : public ModelObject { + public: + /** @name Constructors and Destructors */ + //@{ + + virtual ~OutputEnergyManagementSystem() {} + + //@} + + static IddObjectType iddObjectType(); + + static std::vector actuatorAvailabilityDictionaryReportingValues(); + + static std::vector internalVariableAvailabilityDictionaryReportingValues(); + + static std::vector eMSRuntimeLanguageDebugOutputLevelValues(); + + /** @name Getters */ + //@{ + + std::string actuatorAvailabilityDictionaryReporting() const; + + bool isActuatorAvailabilityDictionaryReportingDefaulted() const; + + std::string internalVariableAvailabilityDictionaryReporting() const; + + bool isInternalVariableAvailabilityDictionaryReportingDefaulted() const; + + std::string eMSRuntimeLanguageDebugOutputLevel() const; + + bool isEMSRuntimeLanguageDebugOutputLevelDefaulted() const; + + //@} + /** @name Setters */ + //@{ + + bool setActuatorAvailabilityDictionaryReporting(const std::string& actuatorAvailabilityDictionaryReporting); + + void resetActuatorAvailabilityDictionaryReporting(); + + bool setInternalVariableAvailabilityDictionaryReporting(const std::string& internalVariableAvailabilityDictionaryReporting); + + void resetInternalVariableAvailabilityDictionaryReporting(); + + bool setEMSRuntimeLanguageDebugOutputLevel(const std::string& eMSRuntimeLanguageDebugOutputLevel); + + void resetEMSRuntimeLanguageDebugOutputLevel(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + /// @cond + typedef detail::OutputEnergyManagementSystem_Impl ImplType; + + explicit OutputEnergyManagementSystem(std::shared_ptr impl); + + friend class detail::OutputEnergyManagementSystem_Impl; + friend class Model; + friend class IdfObject; + friend class openstudio::detail::IdfObject_Impl; + explicit OutputEnergyManagementSystem(Model& model); + + /// @endcond + private: + REGISTER_LOGGER("openstudio.model.OutputEnergyManagementSystem"); +}; + +/** \relates OutputEnergyManagementSystem*/ +typedef boost::optional OptionalOutputEnergyManagementSystem; + +/** \relates OutputEnergyManagementSystem*/ +typedef std::vector OutputEnergyManagementSystemVector; + +} // model +} // openstudio + +#endif // MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_HPP + diff --git a/openstudiocore/src/model/OutputEnergyManagementSystem_Impl.hpp b/openstudiocore/src/model/OutputEnergyManagementSystem_Impl.hpp new file mode 100644 index 00000000000..1f1679d353d --- /dev/null +++ b/openstudiocore/src/model/OutputEnergyManagementSystem_Impl.hpp @@ -0,0 +1,107 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#ifndef MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_IMPL_HPP +#define MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_IMPL_HPP + +#include +#include "ModelObject_Impl.hpp" + +namespace openstudio { +namespace model { + +namespace detail { + + /** OutputEnergyManagementSystem_Impl is a ModelObject_Impl that is the implementation class for OutputEnergyManagementSystem.*/ + class MODEL_API OutputEnergyManagementSystem_Impl : public ModelObject_Impl { + public: + /** @name Constructors and Destructors */ + //@{ + + OutputEnergyManagementSystem_Impl(const IdfObject& idfObject, + Model_Impl* model, + bool keepHandle); + + OutputEnergyManagementSystem_Impl(const openstudio::detail::WorkspaceObject_Impl& other, + Model_Impl* model, + bool keepHandle); + + OutputEnergyManagementSystem_Impl(const OutputEnergyManagementSystem_Impl& other, + Model_Impl* model, + bool keepHandle); + + virtual ~OutputEnergyManagementSystem_Impl() {} + + //@} + /** @name Virtual Methods */ + //@{ + + virtual const std::vector& outputVariableNames() const; + + virtual IddObjectType iddObjectType() const; + + //@} + /** @name Getters */ + //@{ + + std::string actuatorAvailabilityDictionaryReporting() const; + + bool isActuatorAvailabilityDictionaryReportingDefaulted() const; + + std::string internalVariableAvailabilityDictionaryReporting() const; + + bool isInternalVariableAvailabilityDictionaryReportingDefaulted() const; + + std::string eMSRuntimeLanguageDebugOutputLevel() const; + + bool isEMSRuntimeLanguageDebugOutputLevelDefaulted() const; + + //@} + /** @name Setters */ + //@{ + + bool setActuatorAvailabilityDictionaryReporting(const std::string& actuatorAvailabilityDictionaryReporting); + + void resetActuatorAvailabilityDictionaryReporting(); + + bool setInternalVariableAvailabilityDictionaryReporting(const std::string& internalVariableAvailabilityDictionaryReporting); + + void resetInternalVariableAvailabilityDictionaryReporting(); + + bool setEMSRuntimeLanguageDebugOutputLevel(const std::string& eMSRuntimeLanguageDebugOutputLevel); + + void resetEMSRuntimeLanguageDebugOutputLevel(); + + //@} + /** @name Other */ + //@{ + + //@} + protected: + private: + REGISTER_LOGGER("openstudio.model.OutputEnergyManagementSystem"); + }; + +} // detail + +} // model +} // openstudio + +#endif // MODEL_OUTPUTENERGYMANAGEMENTSYSTEM_IMPL_HPP + From 02579c2a8cd747158b8a9c2ff290c74441719ca9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 14:13:56 -0600 Subject: [PATCH 078/159] outputEMS idd change --- openstudiocore/resources/model/OpenStudio.idd | 1 - 1 file changed, 1 deletion(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 20edad70f30..50fb3ff25b7 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26370,7 +26370,6 @@ OS:Meter:CustomDecrement, OS:Output:EnergyManagementSystem, \memo This object is used to control the output produced by the Energy Management System \unique-object - \min-fields 2 A1, \field Handle \type handle \required-field From 5527e41ec0169be269a8a4a13a2176b9da1203d9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 14:58:42 -0600 Subject: [PATCH 079/159] globalVariable/Subroutine in ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 2 + .../src/energyplus/ForwardTranslator.cpp | 16 ++++- .../src/energyplus/ForwardTranslator.hpp | 6 ++ ...teEnergyManagementSystemGlobalVariable.cpp | 70 +++++++++++++++++++ ...nslateEnergyManagementSystemSubroutine.cpp | 69 ++++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index d67230148f5..919948b0c21 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -120,9 +120,11 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterInverterSimple.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeFluidCoolerSingleSpeed.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 3b842bf5c17..21a6d542e95 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1329,6 +1329,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemActuator(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable: + { + model::EnergyManagementSystemGlobalVariable temp = modelObject.cast(); + retVal = translateEnergyManagementSystemGlobalVariable(temp); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_Program: { model::EnergyManagementSystemProgram temp = modelObject.cast(); @@ -1347,6 +1353,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemSensor(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_Subroutine: + { + model::EnergyManagementSystemSubroutine temp = modelObject.cast(); + retVal = EnergyManagementSystemSubroutine(temp); + break; + } case openstudio::IddObjectType::OS_EvaporativeCooler_Direct_ResearchSpecial : { model::EvaporativeCoolerDirectResearchSpecial evap = modelObject.cast(); @@ -2954,10 +2966,12 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_Meter_CustomDecrement); result.push_back(IddObjectType::OS_Output_Variable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); result.push_back(IddObjectType::OS_EnergyManagementSystem_Actuator); result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); + result.push_back(IddObjectType::OS_EnergyManagementSystem_Subroutine); result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); - result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); + result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); return result; } diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 8610d8a21e7..2dcaff46a13 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -144,9 +144,11 @@ class ElectricLoadCenterInverterLookUpTable; class ElectricLoadCenterInverterSimple; class ElectricLoadCenterStorageSimple; class EnergyManagementSystemActuator; +class EnergyManagementSystemGlobalVariable; class EnergyManagementSystemProgram; class EnergyManagementSystemProgramCallingManager; class EnergyManagementSystemSensor; +class EnergyManagementSystemSubroutine; class EvaporativeCoolerDirectResearchSpecial; class EvaporativeCoolerIndirectResearchSpecial; class EvaporativeFluidCoolerSingleSpeed; @@ -646,12 +648,16 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateEnergyManagementSystemActuator(model::EnergyManagementSystemActuator & modelObejct); + boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObejct ); + boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObejct); boost::optional translateEnergyManagementSystemProgramCallingManager(model::EnergyManagementSystemProgramCallingManager & modelObejct); boost::optional translateEnergyManagementSystemSensor(model::EnergyManagementSystemSensor & modelObejct ); + boost::optional translateEnergyManagementSystemSubroutine(model::EnergyManagementSystemSubroutine & modelObejct ); + boost::optional translateEvaporativeFluidCoolerSingleSpeed( model::EvaporativeFluidCoolerSingleSpeed & modelObject ); boost::optional translateEvaporativeFluidCoolerTwoSpeed( model::EvaporativeFluidCoolerTwoSpeed & modelObject ); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp new file mode 100644 index 00000000000..117760eb058 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp @@ -0,0 +1,70 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemGlobalVariable(EnergyManagementSystemGlobalVariable & modelObject) +{ + boost::optional d; + boost::optional m; + boost::optional s; + + //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); + //m_idfObjects.push_back(idfObject); + IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable, modelObject); + + //Name + s = modelObject.name(); + if (s) { + program.setName(*s); + } + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + program.pushExtensibleGroup(eg.fields()); + } + return program; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp new file mode 100644 index 00000000000..85cf0c6fac0 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -0,0 +1,69 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemSubroutine.hpp" +#include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemSubroutine(EnergyManagementSystemSubroutine & modelObject) +{ + boost::optional s; + + //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + //m_idfObjects.push_back(idfObject); + IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine, modelObject); + //Name + s = modelObject.name(); + if (s) { + program.setName(*s); + } + + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + program.pushExtensibleGroup(eg.fields()); + } + return program; +} + +} // energyplus + +} // openstudio + From 306247d3c2345aec29b7ac5ed406f8e9777b1bdb Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 15:10:14 -0600 Subject: [PATCH 080/159] OutputVariable in ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 7 ++ .../src/energyplus/ForwardTranslator.hpp | 3 + ...teEnergyManagementSystemOutputVariable.cpp | 84 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 919948b0c21..28485bda920 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -121,6 +121,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 21a6d542e95..02aa4b03586 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1335,6 +1335,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemGlobalVariable(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable: + { + model::EnergyManagementSystemOutputVariable temp = modelObject.cast(); + retVal = translateEnergyManagementSystemOutputVariable(temp); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_Program: { model::EnergyManagementSystemProgram temp = modelObject.cast(); @@ -2971,6 +2977,7 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); result.push_back(IddObjectType::OS_EnergyManagementSystem_Subroutine); result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); + result.push_back(IddObjectType::OS_EnergyManagementSystem_OutputVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); return result; diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 2dcaff46a13..0d89b527596 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -145,6 +145,7 @@ class ElectricLoadCenterInverterSimple; class ElectricLoadCenterStorageSimple; class EnergyManagementSystemActuator; class EnergyManagementSystemGlobalVariable; +class EnergyManagementSystemOutputVariable; class EnergyManagementSystemProgram; class EnergyManagementSystemProgramCallingManager; class EnergyManagementSystemSensor; @@ -650,6 +651,8 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObejct ); + boost::optional translateEnergyManagementSystemOutputVariable(model::EnergyManagementSystemOutputVariable & modelObejct ); + boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObejct); boost::optional translateEnergyManagementSystemProgramCallingManager(model::EnergyManagementSystemProgramCallingManager & modelObejct); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp new file mode 100644 index 00000000000..ce67f7cb21c --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp @@ -0,0 +1,84 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemOutputVariable.hpp" +#include "../../model/EnergyManagementSystemOutputVariable_Impl.hpp" + + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemOutputVariable(EnergyManagementSystemOutputVariable & modelObject) +{ + boost::optional m; + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_OutputVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + s = modelObject.eMSVariableName(); + if (s) { + idfObject.setString(EnergyManagementSystem_OutputVariableFields::EMSVariableName, s.get()); + } + s = modelObject.typeofDatainVariable(); + if (s.is_initialized()) { + idfObject.setString(EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable, s.get()); + } + s = modelObject.updateFrequency(); + if (s.is_initialized()){ + idfObject.setString(EnergyManagementSystem_OutputVariableFields::UpdateFrequency, s.get()); + } + m = modelObject.eMSProgramorSubroutineName(); + if (m.is_initialized()) { + idfObject.setString(EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, m.get()); + } + m = modelObject.units(); + if (m.is_initialized()) { + idfObject.setString(EnergyManagementSystem_OutputVariableFields::Units, m.get()); + } + + return idfObject; +} + +} // energyplus + +} // openstudio + From 055dabb0ad35d39d401131fcf941bd7f97e6974c Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 15:17:35 -0600 Subject: [PATCH 081/159] TrendVariable in ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 7 ++ .../src/energyplus/ForwardTranslator.hpp | 3 + ...ateEnergyManagementSystemTrendVariable.cpp | 72 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 28485bda920..f4484046d5c 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -126,6 +126,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerDirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeCoolerIndirectResearchSpecial.cpp ForwardTranslator/ForwardTranslateEvaporativeFluidCoolerSingleSpeed.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 02aa4b03586..fd417032dce 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1365,6 +1365,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = EnergyManagementSystemSubroutine(temp); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_TrendVariable: + { + model::EnergyManagementSystemTrendVariable temp = modelObject.cast(); + retVal = translateEnergyManagementSystemTrendVariable(temp); + break; + } case openstudio::IddObjectType::OS_EvaporativeCooler_Direct_ResearchSpecial : { model::EvaporativeCoolerDirectResearchSpecial evap = modelObject.cast(); @@ -2979,6 +2985,7 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); result.push_back(IddObjectType::OS_EnergyManagementSystem_OutputVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_TrendVariable); return result; } diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 0d89b527596..412c4071d97 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -150,6 +150,7 @@ class EnergyManagementSystemProgram; class EnergyManagementSystemProgramCallingManager; class EnergyManagementSystemSensor; class EnergyManagementSystemSubroutine; +class EnergyManagementSystemTrendVariable; class EvaporativeCoolerDirectResearchSpecial; class EvaporativeCoolerIndirectResearchSpecial; class EvaporativeFluidCoolerSingleSpeed; @@ -661,6 +662,8 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateEnergyManagementSystemSubroutine(model::EnergyManagementSystemSubroutine & modelObejct ); + boost::optional translateEnergyManagementSystemTrendVariable(model::EnergyManagementSystemTrendVariable & modelObejct ); + boost::optional translateEvaporativeFluidCoolerSingleSpeed( model::EvaporativeFluidCoolerSingleSpeed & modelObject ); boost::optional translateEvaporativeFluidCoolerTwoSpeed( model::EvaporativeFluidCoolerTwoSpeed & modelObject ); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp new file mode 100644 index 00000000000..c50c0154c05 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp @@ -0,0 +1,72 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemTrendVariable.hpp" +#include "../../model/EnergyManagementSystemTrendVariable_Impl.hpp" + + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemTrendVariable(EnergyManagementSystemTrendVariable & modelObject) +{ + boost::optional i; + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_TrendVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + s = modelObject.eMSVariableName(); + if (s) { + idfObject.setString(EnergyManagementSystem_TrendVariableFields::EMSVariableName, s.get()); + } + i = modelObject.numberofTimestepstobeLogged(); + if (i.is_initialized()) { + idfObject.setInt(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, i.get()); + } + + return idfObject; +} + +} // energyplus + +} // openstudio + From c1dea64a19dcce5fc70519f18531e0f884f9e15e Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 15:33:36 -0600 Subject: [PATCH 082/159] outputEMS to ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 7 ++ .../src/energyplus/ForwardTranslator.hpp | 3 + ...dTranslateOutputEnergyManagementSystem.cpp | 75 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateOutputEnergyManagementSystem.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index f4484046d5c..c9d3b178a49 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -176,6 +176,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateOutputControlReportingTolerances.cpp ForwardTranslator/ForwardTranslateOutputMeter.cpp ForwardTranslator/ForwardTranslateOutputVariable.cpp + ForwardTranslator/ForwardTranslateOutputEnergyManagementSystem.cpp ForwardTranslator/ForwardTranslatePeople.cpp ForwardTranslator/ForwardTranslatePhotovoltaicPerformanceEquivalentOneDiode.cpp ForwardTranslator/ForwardTranslatePhotovoltaicPerformanceSimple.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index fd417032dce..c37500f9e4d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1863,6 +1863,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateOutputVariable(outputVariable); break; } + case openstudio::IddObjectType::OS_Output_EnergyManagementSystem: + { + model::Output_EnergyManagementSystem temp = modelObject.cast(); + retVal = translateOutputEnergyManagementSystem(temp); + break; + } case openstudio::IddObjectType::OS_People : { model::People people = modelObject.cast(); @@ -2986,6 +2992,7 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_EnergyManagementSystem_OutputVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_TrendVariable); + result.push_back(IddObjectType::OS_Output_EnergyManagementSystem); return result; } diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 412c4071d97..616e7213f23 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -200,6 +200,7 @@ class OutsideSurfaceConvectionAlgorithm; class OutputControlReportingTolerances; class OutputMeter; class OutputVariable; +class OutputEnergyManagementSystem; class People; class PhotovoltaicPerformanceEquivalentOneDiode; class PhotovoltaicPerformanceSimple; @@ -762,6 +763,8 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateOutputVariable( model::OutputVariable & modelObject ); + boost::optional translateOutputEnergyManagementSystem(model::OutputEnergyManagementSystem & modelObejct); + boost::optional translatePeople( model::People & modelObject ); boost::optional translatePhotovoltaicPerformanceEquivalentOneDiode(model::PhotovoltaicPerformanceEquivalentOneDiode & modelObject); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateOutputEnergyManagementSystem.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateOutputEnergyManagementSystem.cpp new file mode 100644 index 00000000000..a3399c0f54f --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateOutputEnergyManagementSystem.cpp @@ -0,0 +1,75 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/OutputEnergyManagementSystem.hpp" +#include "../../model/OutputEnergyManagementSystem_Impl.hpp" + + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateOutputEnergyManagementSystem(OutputEnergyManagementSystem & modelObject) +{ + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::Output_EnergyManagementSystem); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + s = modelObject.actuatorAvailabilityDictionaryReporting(); + if (s) { + idfObject.setString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting, s.get()); + } + s = modelObject.internalVariableAvailabilityDictionaryReporting(); + if (s.is_initialized()) { + idfObject.setString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting, s.get()); + } + s = modelObject.eMSRuntimeLanguageDebugOutputLevel(); + if (s.is_initialized()) { + idfObject.setString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel, s.get()); + } + + return idfObject; +} + +} // energyplus + +} // openstudio + From 55bd9197c929215e8daa205c9f9f8151e343f652 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 26 Aug 2016 18:34:43 -0600 Subject: [PATCH 083/159] typo --- openstudiocore/src/energyplus/ForwardTranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index c37500f9e4d..5178ab18acd 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1865,7 +1865,7 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb } case openstudio::IddObjectType::OS_Output_EnergyManagementSystem: { - model::Output_EnergyManagementSystem temp = modelObject.cast(); + model::OutputEnergyManagementSystem temp = modelObject.cast(); retVal = translateOutputEnergyManagementSystem(temp); break; } From 5b504998b42e0070be94961e4bebd87bdaa6c401 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sat, 27 Aug 2016 16:38:50 -0600 Subject: [PATCH 084/159] EMS Subroutine model GTest --- openstudiocore/src/model/CMakeLists.txt | 1 + ...EnergyManagementSystemSubroutine_GTest.cpp | 205 ++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index f566b7155fd..b719895859b 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1643,6 +1643,7 @@ set(${target_name}_test_src test/EnergyManagementSystemProgram_GTest.cpp test/EnergyManagementSystemProgramCallingManager_GTest.cpp test/EnergyManagementSystemSensor_GTest.cpp + test/EnergyManagementSystemSubroutine_GTest.cpp test/EvaporativeCoolerDirectResearchSpecial_GTest.cpp test/EvaporativeCoolerIndirectResearchSpecial_GTest.cpp test/EvaporativeFluidCoolerSingleSpeed_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp new file mode 100644 index 00000000000..cc07630d301 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp @@ -0,0 +1,205 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../FanConstantVolume.hpp" +#include "../FanConstantVolume_Impl.hpp" +#include "../Schedule.hpp" +#include "../EnergyManagementSystemActuator.hpp" +#include "../EnergyManagementSystemProgram.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemSubroutine.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" +#include "../../utilities/core/UUID.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + + //add program + EnergyManagementSystemSubroutine fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + boost::optional> lines = fan_program_1.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_1.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); + fanActuator.remove(); + EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); + + //add actuator on fan again + EnergyManagementSystemActuator fanActuator2(fan); + fanName = fan.name().get() + "Press Actuator"; + fanActuator2.setName(fanName); + fanControlType = "Fan Pressure Rise"; + fanActuator2.setActuatedComponentControlType(fanControlType); + + // Create a second program from a vector of lines + EnergyManagementSystemSubroutine fan_program_2(model); + programName = fan.name().get() + "Pressure Rise Program by Line"; + fan_program_2.setName(programName); + //create program by individual lines + std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + + fan_program_2.addLine(line1); + fan_program_2.addLine(line2); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_2.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_2.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_2.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); + OATdbSensor.remove(); + EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); + + //add sensor back in + EnergyManagementSystemSensor OATdbSensor2(model); + OATdbSensor2.setName("OATdb Sensor"); + OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + // # Create a third program from vector of lines + EnergyManagementSystemSubroutine fan_program_3(model); + programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; + fan_program_3.setName(programName); + + std::vector vectorOfLines; + line1 = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\r\n"; + line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + vectorOfLines.push_back(line1); + vectorOfLines.push_back(line2); + fan_program_3.setLines(vectorOfLines); + + //this is what the body should look like with 2 /n's and compare TRUE + fan_program_body_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + line1_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\n"; + line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; + + //check body + body = fan_program_3.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + EXPECT_EQ(2, fan_program_3.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); + OATdbSensor2.remove(); + EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); + fanActuator2.remove(); + EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().size()); + + lines = fan_program_3.lines(); + EXPECT_EQ(2, lines.get().size()); + fan_program_3.addLine(line1); + lines = fan_program_3.lines(); + EXPECT_EQ(3, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[2]); + fan_program_3.eraseBody(); + body = fan_program_3.body(); + EXPECT_EQ("", body.get()); + +} + From 1da94e284bb536810671362eb31701cf82b01492 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 10:53:59 -0600 Subject: [PATCH 085/159] global variable test --- openstudiocore/src/model/CMakeLists.txt | 1 + ...gyManagementSystemGlobalVariable_GTest.cpp | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index b719895859b..49e0266d60e 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1640,6 +1640,7 @@ set(${target_name}_test_src test/ElectricLoadCenterInverterLookUpTable_GTest.cpp test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp + test/EnergyManagementSystemGlobalVariable_GTest.cpp test/EnergyManagementSystemProgram_GTest.cpp test/EnergyManagementSystemProgramCallingManager_GTest.cpp test/EnergyManagementSystemSensor_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp new file mode 100644 index 00000000000..0dbfcb8014d --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp @@ -0,0 +1,71 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemGlobalVariable.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../OutputMeter.hpp" +#include "../OutputMeter_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSGlobalVariable_EMSGlobalVariable) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + std::vector vars; + + // add global variable + EnergyManagementSystemGlobalVariable var(model); + // should be empty + EXPECT_EQ(0, var.getVariables().size()); + // add variable + var.addVariable("variable one"); + vars.push_back("variable one"); + + EXPECT_EQ(vars[0], var.getVariables()[0]); + + + + // EXPECT_EQ(siteOutdoorAirDrybulbTemperature, var.outputVariable()); + // EXPECT_EQ("", var.keyName().get()); +} + From 4a0f37a3b3e07c37f9e2381d4ae8e495debd5ee2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 13:09:04 -0600 Subject: [PATCH 086/159] remove extensibleGroups from GlobalVariable and add Name --- openstudiocore/resources/model/OpenStudio.idd | 4 +--- ...teEnergyManagementSystemGlobalVariable.cpp | 20 +++++++++---------- .../EnergyManagementSystemGlobalVariable.cpp | 10 +++++++--- .../EnergyManagementSystemGlobalVariable.hpp | 10 +++++----- ...rgyManagementSystemGlobalVariable_Impl.hpp | 8 ++++---- ...gyManagementSystemGlobalVariable_GTest.cpp | 17 ++-------------- 6 files changed, 29 insertions(+), 40 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 50fb3ff25b7..3e773940baf 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26522,15 +26522,13 @@ OS:EnergyManagementSystem:Subroutine, \required-field OS:EnergyManagementSystem:GlobalVariable, - \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. \memo Declares Erl variable as having global scope \memo No spaces allowed in names used for Erl variables \min-fields 2 A1, \field Handle \type handle \required-field - A2 ; \field Erl Variable Name - \begin-extensible + A2 ; \field Name \required-field \type alpha \note no spaces allowed in name diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp index 117760eb058..59a7e4af0a1 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp @@ -45,23 +45,23 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemGlobalVariable(EnergyManagementSystemGlobalVariable & modelObject) { - boost::optional d; - boost::optional m; + //boost::optional d; + //boost::optional m; boost::optional s; - //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); - //m_idfObjects.push_back(idfObject); - IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable, modelObject); + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); + m_idfObjects.push_back(idfObject); + //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable, modelObject); //Name s = modelObject.name(); if (s) { - program.setName(*s); + idfObject.setName(*s); } - for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { - program.pushExtensibleGroup(eg.fields()); - } - return program; + //for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + // program.pushExtensibleGroup(eg.fields()); + //} + return idfObject; } } // energyplus diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp index 4ab348c3387..f91c0540f76 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -66,7 +66,7 @@ namespace detail { return EnergyManagementSystemGlobalVariable::iddObjectType(); } - bool EnergyManagementSystemGlobalVariable_Impl::addVariable(const std::string& variable) { + /* bool EnergyManagementSystemGlobalVariable_Impl::addVariable(const std::string& variable) { //set global variable bool result = false; @@ -110,18 +110,21 @@ namespace detail { //erase all Variables in this global variable object clearExtensibleGroups(); } + */ } // detail -EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const Model& model) +EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const std::string& variableName, const Model& model) : ModelObject(EnergyManagementSystemGlobalVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + bool test = getImpl()->setName(variableName); + OS_ASSERT(test); } IddObjectType EnergyManagementSystemGlobalVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); } - +/* bool EnergyManagementSystemGlobalVariable::addVariable(const std::string& variable) { return getImpl()->addVariable(variable); } @@ -138,6 +141,7 @@ void EnergyManagementSystemGlobalVariable::eraseVariables() { getImpl()->eraseVariables(); } +*/ /// @cond EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp index 70eb7e3e60e..acf6cb23aa1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -38,7 +38,7 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemGlobalVariable(const Model& model); + explicit EnergyManagementSystemGlobalVariable(const std::string& variableName, const Model& model); virtual ~EnergyManagementSystemGlobalVariable() {} @@ -49,17 +49,17 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { /** @name Getters */ //@{ - std::vector getVariables() const; + //std::vector getVariables() const; //@} /** @name Setters */ //@{ - bool addVariable(const std::string& variable); + //bool addVariable(const std::string& variable); - bool removeVariable(const std::string& variable); + //bool removeVariable(const std::string& variable); - void eraseVariables(); + //void eraseVariables(); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp index e3a857bef4a..4c4a5c37ff3 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp @@ -60,17 +60,17 @@ namespace detail { /** @name Getters */ //@{ - std::vector getVariables() const; + //std::vector getVariables() const; //@} /** @name Setters */ //@{ - bool addVariable(const std::string& variable); + //bool addVariable(const std::string& variable); - bool removeVariable(const std::string& variable); + //bool removeVariable(const std::string& variable); - void eraseVariables(); + //void eraseVariables(); //@} /** @name Other */ diff --git a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp index 0dbfcb8014d..51bb911a802 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp @@ -51,21 +51,8 @@ TEST_F(ModelFixture, EMSGlobalVariable_EMSGlobalVariable) ThermalZone zone1(model); ThermalZone zone2(model); - std::vector vars; - // add global variable - EnergyManagementSystemGlobalVariable var(model); - // should be empty - EXPECT_EQ(0, var.getVariables().size()); - // add variable - var.addVariable("variable one"); - vars.push_back("variable one"); - - EXPECT_EQ(vars[0], var.getVariables()[0]); - - - - // EXPECT_EQ(siteOutdoorAirDrybulbTemperature, var.outputVariable()); - // EXPECT_EQ("", var.keyName().get()); + EnergyManagementSystemGlobalVariable var("glob var", model); + EXPECT_EQ("glob var", var.nameString()); } From 4dda9f510b2b9a5a764e6f2f3c001c3041a8d7ce Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 16:21:50 -0600 Subject: [PATCH 087/159] Gtest outputVariable --- ...TranslateEnergyManagementSystemProgram.cpp | 1 + openstudiocore/src/model/CMakeLists.txt | 1 + .../EnergyManagementSystemOutputVariable.cpp | 5 + ...gyManagementSystemGlobalVariable_GTest.cpp | 15 +-- ...gyManagementSystemOutputVariable_GTest.cpp | 122 ++++++++++++++++++ 5 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index 34ae9272ca6..83b697ad13d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -57,6 +57,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro program.setName(*s); } + //TODO translate UIDs to UID.name in the program for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { program.pushExtensibleGroup(eg.fields()); } diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 49e0266d60e..6150fe36bd7 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1641,6 +1641,7 @@ set(${target_name}_test_src test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp test/EnergyManagementSystemGlobalVariable_GTest.cpp + test/EnergyManagementSystemOutputVariable_GTest.cpp test/EnergyManagementSystemProgram_GTest.cpp test/EnergyManagementSystemProgramCallingManager_GTest.cpp test/EnergyManagementSystemSensor_GTest.cpp diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 76c881a9e7b..a7d40092110 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -118,6 +118,9 @@ namespace detail { bool EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, units); + OS_ASSERT(result); + std::string name = this->nameString(); + result = setString(OS_EnergyManagementSystem_OutputVariableFields::Name, name + " [" + units + "]"); return result; } @@ -132,6 +135,8 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + //bool test = getImpl()->setUpdateFrequency("SystemTimestep"); + //OS_ASSERT(test); } IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp index 51bb911a802..db56b3a6748 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp @@ -20,15 +20,7 @@ #include #include "ModelFixture.hpp" -#include "../Building.hpp" -#include "../Building_Impl.hpp" -#include "../ThermalZone.hpp" -#include "../EnergyManagementSystemSensor.hpp" #include "../EnergyManagementSystemGlobalVariable.hpp" -#include "../OutputVariable.hpp" -#include "../OutputVariable_Impl.hpp" -#include "../OutputMeter.hpp" -#include "../OutputMeter_Impl.hpp" #include "../Model_Impl.hpp" #include "../../utilities/idd/IddEnums.hpp" @@ -45,12 +37,7 @@ using std::string; TEST_F(ModelFixture, EMSGlobalVariable_EMSGlobalVariable) { Model model; - - Building building = model.getUniqueModelObject(); - - ThermalZone zone1(model); - ThermalZone zone2(model); - + // add global variable EnergyManagementSystemGlobalVariable var("glob var", model); EXPECT_EQ("glob var", var.nameString()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp new file mode 100644 index 00000000000..78d76623c44 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -0,0 +1,122 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../FanConstantVolume.hpp" +#include "../FanConstantVolume_Impl.hpp" +#include "../Schedule.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemActuator.hpp" +#include "../EnergyManagementSystemGlobalVariable.hpp" +#include "../EnergyManagementSystemOutputVariable.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../OutputMeter.hpp" +#include "../OutputMeter_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) +{ + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add global variable + EnergyManagementSystemGlobalVariable var("globalVar", model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + // add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + // add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + FanConstantVolume fan2(model, s); + + // add actuator + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + + // add output variable + EnergyManagementSystemOutputVariable outvar(model); + //setname + outvar.setName("outputVar"); + EXPECT_EQ("outputVar", outvar.nameString()); + + //variable name + bool varset = outvar.setEMSVariableName("badVariable"); + //TODO above should fail + //EXPECT_EQ(false,varset); + varset = outvar.setEMSVariableName("globalVar"); + EXPECT_EQ(true, varset); + + //set units + //outvar.setUnits("C"); + //EXPECT_EQ("C", outvar.units().get()); + //check name has units + //EXPECT_EQ("output var [C]", outvar.nameString()); + //update frequency + bool update = outvar.setUpdateFrequency("BadValue"); + EXPECT_EQ(false, update); + outvar.setUpdateFrequency("ZoneTimestep"); + EXPECT_EQ("ZoneTimestep", outvar.updateFrequency()); + outvar.setUpdateFrequency("SystemTimestep"); + EXPECT_EQ("SystemTimestep", outvar.updateFrequency()); + //type of data in variable + update = outvar.setTypeofDatainVariable("BadValue"); + EXPECT_EQ(false, update); + outvar.setTypeofDatainVariable("Averaged"); + EXPECT_EQ("Averaged", outvar.typeofDatainVariable()); + outvar.setTypeofDatainVariable("Summed"); + EXPECT_EQ("Summed", outvar.typeofDatainVariable()); + //program or subroutine name + bool init = outvar.eMSProgramorSubroutineName().is_initialized(); + EXPECT_EQ(false, init); + outvar.setEMSProgramorSubroutineName("program name"); + EXPECT_EQ("program name", outvar.eMSProgramorSubroutineName().get()); + + +} + From a0f8dd365e7e746c821895bc9e81e8b13070b283 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 16:47:26 -0600 Subject: [PATCH 088/159] InternalVariable GTest --- openstudiocore/src/model/CMakeLists.txt | 1 + ...ManagementSystemInternalVariable_GTest.cpp | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 6150fe36bd7..b44b621f667 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1641,6 +1641,7 @@ set(${target_name}_test_src test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp test/EnergyManagementSystemGlobalVariable_GTest.cpp + test/EnergyManagementSystemInternalVariable_GTest.cpp test/EnergyManagementSystemOutputVariable_GTest.cpp test/EnergyManagementSystemProgram_GTest.cpp test/EnergyManagementSystemProgramCallingManager_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp new file mode 100644 index 00000000000..809bda9a310 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp @@ -0,0 +1,50 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../EnergyManagementSystemInternalVariable.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSInternalVariable_EMSInternalVariable) +{ + Model model; + + // add internal variable + EnergyManagementSystemInternalVariable var(model); + var.setInternalDataIndexKeyName("TestName"); + EXPECT_EQ("TestName", var.internalDataIndexKeyName().get()); + var.resetInternalDataIndexKeyName(); + EXPECT_EQ("", var.internalDataIndexKeyName().get()); + var.setInternalDataType("TestName"); + EXPECT_EQ("TestName", var.internalDataType()); +} + From a7bd6ed57a30bcf3ae0543b73f72df8f2a9432f2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 17:18:00 -0600 Subject: [PATCH 089/159] Gtest TendVariable --- openstudiocore/src/model/CMakeLists.txt | 1 + ...rgyManagementSystemTrendVariable_GTest.cpp | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index b44b621f667..597b1679550 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1647,6 +1647,7 @@ set(${target_name}_test_src test/EnergyManagementSystemProgramCallingManager_GTest.cpp test/EnergyManagementSystemSensor_GTest.cpp test/EnergyManagementSystemSubroutine_GTest.cpp + test/EnergyManagementSystemTrendVariable_GTest.cpp test/EvaporativeCoolerDirectResearchSpecial_GTest.cpp test/EvaporativeCoolerIndirectResearchSpecial_GTest.cpp test/EvaporativeFluidCoolerSingleSpeed_GTest.cpp diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp new file mode 100644 index 00000000000..5db9ec31042 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -0,0 +1,49 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../EnergyManagementSystemTrendVariable.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) +{ + Model model; + + // add internal variable + EnergyManagementSystemTrendVariable var(model); + var.setEMSVariableName("TestName"); + EXPECT_EQ("TestName", var.eMSVariableName()); + + var.setNumberofTimestepstobeLogged(2); + EXPECT_EQ(2, var.numberofTimestepstobeLogged()); +} + From 4bfc5157736f3254564e24672db9463e82ed9563 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 30 Aug 2016 22:07:10 -0600 Subject: [PATCH 090/159] invernalVariable return type change outputVariable idd change --- openstudiocore/resources/model/OpenStudio.idd | 2 +- .../EnergyManagementSystemInternalVariable.cpp | 14 ++++++++------ .../EnergyManagementSystemInternalVariable.hpp | 4 ++-- ...EnergyManagementSystemInternalVariable_Impl.hpp | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 3e773940baf..b02bac1490f 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26558,7 +26558,7 @@ OS:EnergyManagementSystem:OutputVariable, \key ZoneTimestep \key SystemTimestep A6 , \field EMS Program or Subroutine Name - \type alpha + \type object-list \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables A7 ; \field Units diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp index 53a28473df1..52460c0b8fd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -74,9 +74,10 @@ namespace detail { return value.get(); } - void EnergyManagementSystemInternalVariable_Impl::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { + bool EnergyManagementSystemInternalVariable_Impl::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, internalDataIndexKeyName); OS_ASSERT(result); + return result; } void EnergyManagementSystemInternalVariable_Impl::resetInternalDataIndexKeyName() { @@ -84,9 +85,10 @@ namespace detail { OS_ASSERT(result); } - void EnergyManagementSystemInternalVariable_Impl::setInternalDataType(const std::string& internalDataType) { + bool EnergyManagementSystemInternalVariable_Impl::setInternalDataType(const std::string& internalDataType) { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType, internalDataType); OS_ASSERT(result); + return result; } } // detail @@ -112,16 +114,16 @@ std::string EnergyManagementSystemInternalVariable::internalDataType() const { return getImpl()->internalDataType(); } -void EnergyManagementSystemInternalVariable::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { - getImpl()->setInternalDataIndexKeyName(internalDataIndexKeyName); +bool EnergyManagementSystemInternalVariable::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { + return getImpl()->setInternalDataIndexKeyName(internalDataIndexKeyName); } void EnergyManagementSystemInternalVariable::resetInternalDataIndexKeyName() { getImpl()->resetInternalDataIndexKeyName(); } -void EnergyManagementSystemInternalVariable::setInternalDataType(const std::string& internalDataType) { - getImpl()->setInternalDataType(internalDataType); +bool EnergyManagementSystemInternalVariable::setInternalDataType(const std::string& internalDataType) { + return getImpl()->setInternalDataType(internalDataType); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp index e7ec12ce554..d3a9ba32e39 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -57,11 +57,11 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { /** @name Setters */ //@{ - void setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); + bool setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); void resetInternalDataIndexKeyName(); - void setInternalDataType(const std::string& internalDataType); + bool setInternalDataType(const std::string& internalDataType); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp index ff6f249cc8e..8b1b28a87aa 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp @@ -68,11 +68,11 @@ namespace detail { /** @name Setters */ //@{ - void setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); + bool setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName); void resetInternalDataIndexKeyName(); - void setInternalDataType(const std::string& internalDataType); + bool setInternalDataType(const std::string& internalDataType); //@} /** @name Other */ From eec3f520b340a64aab2a9043e03232f9c5362d9f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 31 Aug 2016 10:39:44 -0600 Subject: [PATCH 091/159] outputVariable update --- .../model/EnergyManagementSystemOutputVariable.cpp | 5 ----- .../EnergyManagementSystemOutputVariable_GTest.cpp | 13 +++++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index a7d40092110..76c881a9e7b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -118,9 +118,6 @@ namespace detail { bool EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, units); - OS_ASSERT(result); - std::string name = this->nameString(); - result = setString(OS_EnergyManagementSystem_OutputVariableFields::Name, name + " [" + units + "]"); return result; } @@ -135,8 +132,6 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - //bool test = getImpl()->setUpdateFrequency("SystemTimestep"); - //OS_ASSERT(test); } IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 78d76623c44..746d6746156 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -29,6 +29,7 @@ #include "../EnergyManagementSystemSensor.hpp" #include "../EnergyManagementSystemActuator.hpp" #include "../EnergyManagementSystemGlobalVariable.hpp" +#include "../EnergyManagementSystemProgram.hpp" #include "../EnergyManagementSystemOutputVariable.hpp" #include "../OutputVariable.hpp" #include "../OutputVariable_Impl.hpp" @@ -114,8 +115,16 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) //program or subroutine name bool init = outvar.eMSProgramorSubroutineName().is_initialized(); EXPECT_EQ(false, init); - outvar.setEMSProgramorSubroutineName("program name"); - EXPECT_EQ("program name", outvar.eMSProgramorSubroutineName().get()); + bool setprogram = outvar.setEMSProgramorSubroutineName("program name"); + //expect false since program doesnt exist + EXPECT_EQ(false, setprogram); + + // add program + EnergyManagementSystemProgram program(model); + program.setName("program 1"); + setprogram = outvar.setEMSProgramorSubroutineName("program 1"); + EXPECT_EQ(true, setprogram); + EXPECT_EQ("program 1", outvar.eMSProgramorSubroutineName().get()); } From 0816e20acc27e7b7481d4483d0be301013728db9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 31 Aug 2016 11:16:25 -0600 Subject: [PATCH 092/159] output:EMS Gtest --- openstudiocore/src/model/CMakeLists.txt | 1 + .../OutputEnergyManagementSystem_GTest.cpp | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 openstudiocore/src/model/test/OutputEnergyManagementSystem_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 597b1679550..aba9a60837d 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1702,6 +1702,7 @@ set(${target_name}_test_src test/OpaqueMaterial_GTest.cpp test/OtherEquipment_GTest.cpp test/OutputControlReportingTolerances_GTest.cpp + test/OutputEnergyManagementSystem_GTest.cpp test/OutputMeter_GTest.cpp test/OutputVariable_GTest.cpp test/ParentObject_GTest.cpp diff --git a/openstudiocore/src/model/test/OutputEnergyManagementSystem_GTest.cpp b/openstudiocore/src/model/test/OutputEnergyManagementSystem_GTest.cpp new file mode 100644 index 00000000000..7a6df64b8af --- /dev/null +++ b/openstudiocore/src/model/test/OutputEnergyManagementSystem_GTest.cpp @@ -0,0 +1,64 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" + +#include "../OutputEnergyManagementSystem.hpp" +#include "../OutputEnergyManagementSystem_Impl.hpp" +#include "../OutputVariable.hpp" +#include "../OutputVariable_Impl.hpp" +#include "../OutputMeter.hpp" +#include "../OutputMeter_Impl.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSOutput_EMSOutput) +{ + Model model; + + // add Output:EnergyManagementSystem + + OutputEnergyManagementSystem var = model.getUniqueModelObject(); + bool defaulted = var.isActuatorAvailabilityDictionaryReportingDefaulted(); + EXPECT_EQ(true, defaulted); + defaulted = var.isInternalVariableAvailabilityDictionaryReportingDefaulted(); + EXPECT_EQ(true, defaulted); + defaulted = var.isEMSRuntimeLanguageDebugOutputLevelDefaulted(); + EXPECT_EQ(true, defaulted); + var.setActuatorAvailabilityDictionaryReporting("NotByUniqueKeyNames"); + EXPECT_EQ("NotByUniqueKeyNames", var.actuatorAvailabilityDictionaryReporting()); + var.setInternalVariableAvailabilityDictionaryReporting("Verbose"); + EXPECT_EQ("Verbose", var.internalVariableAvailabilityDictionaryReporting()); + var.setEMSRuntimeLanguageDebugOutputLevel("Verbose"); + EXPECT_EQ("Verbose", var.eMSRuntimeLanguageDebugOutputLevel()); + +} + From fdee0db7ae84688dee48f475627821e133ad7953 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 31 Aug 2016 14:09:11 -0600 Subject: [PATCH 093/159] idd change for \object-list add E+ tests --- openstudiocore/resources/model/OpenStudio.idd | 10 +- .../src/energyplus/Test/EMS_GTest.cpp | 125 ++++++++++++++---- ...gyManagementSystemOutputVariable_GTest.cpp | 2 +- 3 files changed, 109 insertions(+), 28 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index b02bac1490f..ef6696fc40a 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26531,6 +26531,7 @@ OS:EnergyManagementSystem:GlobalVariable, A2 ; \field Name \required-field \type alpha + \reference ErlVariableNames \note no spaces allowed in name OS:EnergyManagementSystem:OutputVariable, @@ -26545,7 +26546,8 @@ OS:EnergyManagementSystem:OutputVariable, \retaincase A3 , \field EMS Variable Name \required-field - \type alpha + \type object-list + \object-list ErlVariableNames \note must be an acceptable EMS variable A4 , \field Type of Data in Variable \required-field @@ -26578,7 +26580,8 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \retaincase A3 , \field EMS Variable Name \required-field - \type alpha + \type object-list + \object-list ErlVariableNames \note must be an acceptable EMS variable, no spaces A4 , \field Update Frequency \required-field @@ -26671,7 +26674,8 @@ OS:EnergyManagementSystem:TrendVariable, \reference ErlVariableNames A3 , \field EMS Variable Name \required-field - \type alpha + \type object-list + \object-list ErlVariableNames \note must be a global scope EMS variable N1 ; \field Number of Timesteps to be Logged \required-field diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index f53c35ccf3c..107d6f07b0e 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -34,6 +34,8 @@ #include "../../model/OutputVariable_Impl.hpp" #include "../../model/OutputMeter.hpp" #include "../../model/OutputMeter_Impl.hpp" +#include "../../model/OutputEnergyManagementSystem.hpp" +#include "../../model/OutputEnergyManagementSystem_Impl.hpp" #include "../../model/Schedule.hpp" #include "../../model/Schedule_Impl.hpp" #include "../../model/EnergyManagementSystemSensor.hpp" @@ -58,6 +60,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -76,7 +86,7 @@ using namespace openstudio::model; using namespace openstudio; -TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { +TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { Model model; @@ -87,23 +97,46 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { // add Site Outdoor Air Drybulb Temperature OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); - EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); - EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); // add sensor EnergyManagementSystemSensor OATdbSensor(model); OATdbSensor.setName("OATdb Sensor"); OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); - EXPECT_EQ("OATdb Sensor", OATdbSensor.nameString()); - EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle()); - EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); - EXPECT_EQ("", OATdbSensor.keyName().get()); + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor)[0]; + WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Variable)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); + EXPECT_EQ("OATdb Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); + EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); + //std::string name = outvar.nameString(); + //EXPECT_EQ(name, object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); + + //ASSERT_TRUE(object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)); + //EXPECT_EQ(outvar.handle(), object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)->handle()); + + model.save(toPath("./EMS_sensor1.osm"), true); + workspace.save(toPath("./EMS_sensor1.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { + + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); // add Zone Lights Electric Power to both zones OutputVariable lightsElectricPower("Zone Lights Electric Power", model); - EXPECT_EQ("*", lightsElectricPower.keyValue()); - EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); // add light sensor on zone1 EnergyManagementSystemSensor lights(model); @@ -111,8 +144,26 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { lights.setOutputVariable(lightsElectricPower); lights.setKeyName(zone1.name().get()); - EXPECT_EQ(zone1.name().get(), lights.keyName().get()); - EXPECT_EQ("Light Sensor", lights.nameString()); + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor).size()); + + //EXPECT_EQ(zone1.name().get(), lights.keyName().get()); + //EXPECT_EQ("Light Sensor", lights.nameString()); + + model.save(toPath("./EMS_sensor2.osm"), true); + workspace.save(toPath("./EMS_sensor2.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { + + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); // create meter OutputMeter meter(model); @@ -123,20 +174,18 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor_EMS) { meter_sensor.setName("meter sensor"); meter_sensor.setOutputMeter(meter); - EXPECT_EQ("meter sensor", meter_sensor.nameString()); - EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); - EXPECT_EQ(meter, meter_sensor.outputMeter()); - EXPECT_EQ("", meter_sensor.keyName().get()); - - - //EXPECT_TRUE(model.getOptionalUniqueModelObject()) << "Example model does not include a Version object."; ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - EXPECT_EQ(1u,workspace.getObjectsByType(IddObjectType::Version).size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor).size()); - model.save(toPath("./EMS_example.osm"), true); - workspace.save(toPath("./EMS_example.idf"), true); + //EXPECT_EQ("meter sensor", meter_sensor.nameString()); + //EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); + //EXPECT_EQ(meter, meter_sensor.outputMeter()); + //EXPECT_EQ("", meter_sensor.keyName().get()); + + model.save(toPath("./EMS_sensor_meter.osm"), true); + workspace.save(toPath("./EMS_sensor_meter.idf"), true); } TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { @@ -169,7 +218,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator).size()); model.save(toPath("./EMS_example.osm"), true); workspace.save(toPath("./EMS_example.idf"), true); @@ -336,7 +385,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); + //EXPECT_EQ(3u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); model.save(toPath("./EMS_example.osm"), true); workspace.save(toPath("./EMS_example.idf"), true); @@ -534,8 +583,36 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Version).size()); + //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ProgramCallingManager).size()); model.save(toPath("./EMS_example.osm"), true); workspace.save(toPath("./EMS_example.idf"), true); } + +TEST_F(EnergyPlusFixture, noForwardTranslatorOutput_EMS) { + Model model; + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + EXPECT_EQ(0u, workspace.getObjectsByType(IddObjectType::Output_EnergyManagementSystem).size()); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorOutput_EMS) { + Model model; + OutputEnergyManagementSystem oEMS = model.getUniqueModelObject(); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::Output_EnergyManagementSystem).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::Output_EnergyManagementSystem)[0]; + //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting)); + //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting)); + //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting)); + //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting)); + //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel)); + //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel)); + +} \ No newline at end of file diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 746d6746156..3c33b2dbc69 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -89,7 +89,7 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) //variable name bool varset = outvar.setEMSVariableName("badVariable"); //TODO above should fail - //EXPECT_EQ(false,varset); + EXPECT_EQ(false,varset); varset = outvar.setEMSVariableName("globalVar"); EXPECT_EQ(true, varset); From a4454aa02c189959cebc49a32cd256c5672f9879 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 31 Aug 2016 17:27:31 -0600 Subject: [PATCH 094/159] Variable name instead of name --- .../ForwardTranslateEnergyManagementSystemSensor.cpp | 4 ++-- openstudiocore/src/energyplus/Test/EMS_GTest.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp index 57540573aa3..3fd4f10efbe 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp @@ -61,11 +61,11 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSen } d = modelObject.outputVariable(); if (d.is_initialized()) { - idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, d.get().nameString()); + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, d.get().variableName()); } m = modelObject.outputMeter(); if (m.is_initialized()){ - idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, m.get().nameString()); + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, m.get().name()); } return idfObject; diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 107d6f07b0e..6a5d4d4595a 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -116,9 +116,8 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); - //std::string name = outvar.nameString(); - //EXPECT_EQ(name, object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); - + //EXPECT_EQ("Site Outdoor Air Drybulb Temperature", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); + bool temp = object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName); //ASSERT_TRUE(object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)); //EXPECT_EQ(outvar.handle(), object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)->handle()); From 59636e679cbee59406d9a6a91fb3fed35d09bf9a Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 8 Sep 2016 11:06:46 -0600 Subject: [PATCH 095/159] add comments to program lines correctly --- .../src/energyplus/Test/EMS_GTest.cpp | 166 ++++-------------- .../model/EnergyManagementSystemProgram.cpp | 109 +++++++++++- .../EnergyManagementSystemTrendVariable.cpp | 1 - ...rgyManagementSystemTrendVariable_GTest.cpp | 14 +- 4 files changed, 151 insertions(+), 139 deletions(-) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 6a5d4d4595a..a5b876f03e1 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -116,10 +116,7 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); - //EXPECT_EQ("Site Outdoor Air Drybulb Temperature", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); - bool temp = object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName); - //ASSERT_TRUE(object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)); - //EXPECT_EQ(outvar.handle(), object.getTarget(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName)->handle()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); model.save(toPath("./EMS_sensor1.osm"), true); workspace.save(toPath("./EMS_sensor1.idf"), true); @@ -148,8 +145,15 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { EXPECT_EQ(0u, forwardTranslator.errors().size()); EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor).size()); - //EXPECT_EQ(zone1.name().get(), lights.keyName().get()); - //EXPECT_EQ("Light Sensor", lights.nameString()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor)[0]; + WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Variable)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); + EXPECT_EQ("Light Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); + EXPECT_EQ(zone1.name().get(), object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); + EXPECT_EQ("Zone Lights Electric Power", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); model.save(toPath("./EMS_sensor2.osm"), true); workspace.save(toPath("./EMS_sensor2.idf"), true); @@ -167,6 +171,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { // create meter OutputMeter meter(model); meter.setName("test meter"); + meter.setMeterFileOnly(false); //add sensor to meter EnergyManagementSystemSensor meter_sensor(model); @@ -178,10 +183,15 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { EXPECT_EQ(0u, forwardTranslator.errors().size()); EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor).size()); - //EXPECT_EQ("meter sensor", meter_sensor.nameString()); - //EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); - //EXPECT_EQ(meter, meter_sensor.outputMeter()); - //EXPECT_EQ("", meter_sensor.keyName().get()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Sensor)[0]; + WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Meter)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); + EXPECT_EQ("meter sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); + EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); + EXPECT_EQ("test meter", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false).get()); model.save(toPath("./EMS_sensor_meter.osm"), true); workspace.save(toPath("./EMS_sensor_meter.idf"), true); @@ -198,7 +208,6 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { // add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); - FanConstantVolume fan2(model, s); // add actuator EnergyManagementSystemActuator fanActuator(fan); @@ -206,19 +215,26 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); - EXPECT_EQ(fan, fanActuator.actuatedComponent()); - EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); std::string ComponentType = "Fan"; fanActuator.setActuatedComponentType(ComponentType); - EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); - fanActuator.setActuatedComponent(fan2); - EXPECT_EQ(fan2, fanActuator.actuatedComponent()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator)[0]; + WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Fan_ConstantVolume)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::Name, false)); + EXPECT_EQ(fanName, object.getString(EnergyManagementSystem_ActuatorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false)); + EXPECT_EQ(fan.name().get(), object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false)); + EXPECT_EQ(ComponentType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false)); + EXPECT_EQ(fanControlType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false).get()); + model.save(toPath("./EMS_example.osm"), true); workspace.save(toPath("./EMS_example.idf"), true); } @@ -251,18 +267,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; fanActuator.setActuatedComponentType(ComponentType); - EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); //add program EnergyManagementSystemProgram fan_program_1(model); std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense"; + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; //this is what the body should look like with 2 /n's and compare TRUE - std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; //the added lines should compare TRUE to below - std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\n"; std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //set body @@ -274,120 +289,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { //check lines boost::optional> lines = fan_program_1.lines(); - EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(4, lines.get().size()); EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); - EXPECT_EQ(2, fan_program_1.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); - fanActuator.remove(); - EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); - - //add actuator on fan again - EnergyManagementSystemActuator fanActuator2(fan); - fanName = fan.name().get() + "Press Actuator"; - fanActuator2.setName(fanName); - fanControlType = "Fan Pressure Rise"; - fanActuator2.setActuatedComponentControlType(fanControlType); - ComponentType = "Fan"; - fanActuator2.setActuatedComponentType(ComponentType); - EXPECT_EQ(ComponentType, fanActuator2.actuatedComponentType()); - - // Create a second program from a vector of lines - EnergyManagementSystemProgram fan_program_2(model); - programName = fan.name().get() + "Pressure Rise Program by Line"; - fan_program_2.setName(programName); - //create program by individual lines - std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; - std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; - - fan_program_2.addLine(line1); - fan_program_2.addLine(line2); - - //this is what the body should look like with 2 /n's and compare TRUE - fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; - //the added lines should compare TRUE to below - line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; - line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; - - //check body - body = fan_program_2.body(); - EXPECT_EQ(fan_program_body_test, body.get()); - - //check lines - lines = fan_program_2.lines(); - EXPECT_EQ(2, lines.get().size()); - EXPECT_EQ(line1_test, lines.get()[0]); - EXPECT_EQ(line2_test, lines.get()[1]); - - EXPECT_EQ(2, fan_program_2.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); - OATdbSensor.remove(); - EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); - - //add sensor back in - EnergyManagementSystemSensor OATdbSensor2(model); - OATdbSensor2.setName("OATdb Sensor"); - OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); - - // # Create a third program from vector of lines - EnergyManagementSystemProgram fan_program_3(model); - programName = fan.name().get() + "Pressure Rise Program by Vector of Lines"; - fan_program_3.setName(programName); - - std::vector vectorOfLines; - line1 = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\r\n"; - line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; - vectorOfLines.push_back(line1); - vectorOfLines.push_back(line2); - fan_program_3.setLines(vectorOfLines); - - //this is what the body should look like with 2 /n's and compare TRUE - fan_program_body_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; - //the added lines should compare TRUE to below - line1_test = "SET mult = " + toString(OATdbSensor2.handle()) + " / 15.0 !- This is nonsense\n"; - line2_test = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\n"; - - //check body - body = fan_program_3.body(); - EXPECT_EQ(fan_program_body_test, body.get()); - - //check lines - lines = fan_program_3.lines(); - EXPECT_EQ(2, lines.get().size()); - EXPECT_EQ(line1_test, lines.get()[0]); - EXPECT_EQ(line2_test, lines.get()[1]); - - EXPECT_EQ(2, fan_program_3.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); - EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); - OATdbSensor2.remove(); - EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); - fanActuator2.remove(); - EXPECT_EQ(2, fan_program_3.invalidReferencedObjects().size()); - - lines = fan_program_3.lines(); - EXPECT_EQ(2, lines.get().size()); - fan_program_3.addLine(line1); - lines = fan_program_3.lines(); - EXPECT_EQ(3, lines.get().size()); - EXPECT_EQ(line1_test, lines.get()[2]); - fan_program_3.eraseBody(); - body = fan_program_3.body(); - EXPECT_EQ("", body.get()); - ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - //EXPECT_EQ(3u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); + //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); - model.save(toPath("./EMS_example.osm"), true); - workspace.save(toPath("./EMS_example.idf"), true); + model.save(toPath("./EMS_program.osm"), true); + workspace.save(toPath("./EMS_program.idf"), true); } TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index de2007882ab..c9f35d59176 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -31,6 +31,8 @@ #include "../utilities/core/String.hpp" #include "../utilities/core/StringHelpers.hpp" #include "../utilities/core/UUID.hpp" +#include + //#include "../utilities/idf/Handle.hpp" namespace openstudio { @@ -77,11 +79,26 @@ namespace detail { // loop through extensible groups and add ProgramLine to body string. std::string body; + boost::optional comment; + auto groups = extensibleGroups(); for (auto group = groups.begin(); group != groups.end(); ++group) { + //get program line content const auto & line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); OS_ASSERT(line); body += line.get(); + //get non-default comments if they exist + comment = group->fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, false); + if (comment.is_initialized()) { + //remove space after ! + boost::erase_first(comment.get()," "); + //add space between end of program line and comment + if (!comment.get().empty()) { + body += " " + comment.get(); + } + } + //add newline character + body += '\n'; } return body; } @@ -89,6 +106,7 @@ namespace detail { bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { //set body of program to input string bool result = false; + bool comment_result = false; //if body string empty then return false if (body.empty()) { return false; @@ -104,15 +122,44 @@ namespace detail { body_minus_r.erase(pos, 1); } - //split the body string on newline characters and insert program line for each string line + //split the body string on newline characters and comments and insert program line for each string line std::vector body_minus_nl = splitString(body_minus_r, '\n'); + std::string body_minus_comment; + std::vector comments; + std::string comment; //add program lines to body std::vector ok(body_minus_nl.size(), false); for (size_t i = 0; i < body_minus_nl.size(); i++) { + //split string on comment character ! + comments = splitString(body_minus_nl.at(i), '!'); + //get extensibleGroup object WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, body_minus_nl.at(i) + '\n'); - ok.push_back(result); + //make sure program line exists and insert + if (comments.size() > 0) { + //remove whitespace at end of comments[0] + boost::trim_right(comments[0]); + //insert program line + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); + //check if comments exist + if (comments.size() > 1) { + //clear out the old comment + comment.clear(); + //add comment to comment vector + comment.append(comments.at(1)); + //combine any remaining comments for this line into one comment + if (comments.size() > 2) { + for (size_t j = 2; j < comments.size(); j++) { + comment.append("!" + comments.at(j)); + } + } + comment_result = group.setFieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comment); + } + } else { + result = false; + } + //ok.push_back(result); + ok.at(i) = result; } //check if all the programs set true result = true; @@ -139,6 +186,8 @@ namespace detail { bool EnergyManagementSystemProgram_Impl::addLine(const std::string& line) { //add line to end of program body bool result = true; + bool comment_result = false; + std::string comment; // remove '\r' from the line string std::string line_rn = line; @@ -146,28 +195,74 @@ namespace detail { while ((pos = line_rn.find("\r", pos)) != std::string::npos) { line_rn.erase(pos, 1); } - // remove '\n' since we add it back in below + // remove '\n' pos = 0; while ((pos = line_rn.find("\n", pos)) != std::string::npos) { line_rn.erase(pos, 1); } - + //get extensibleGroup object WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, line_rn + '\n'); + + //split string on comment character ! + std::vector comments = splitString(line_rn, '!'); + //make sure program line exists and insert + if (comments.size() > 0) { + //remove whitespace at end of comments[0] + boost::trim_right(comments[0]); + //insert program line + result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); + //check if comments exist + if (comments.size() > 1) { + //clear out the old comment + comment.clear(); + //add comment to comment vector + comment.append(comments.at(1)); + //combine any remaining comments for this line into one comment + if (comments.size() > 2) { + for (size_t j = 2; j < comments.size(); j++) { + comment.append(", " + comments.at(j)); + } + } + comment_result = group.setFieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comment); + } + } else { + result = false; + } + return result; } boost::optional> EnergyManagementSystemProgram_Impl::lines() const { //return vector of lines from body std::vector result; + boost::optional comment; + std::string whole_line; // loop through extensible groups and add ProgramLine to vector result. auto groups = extensibleGroups(); for (auto group = groups.begin(); group != groups.end(); ++group) { + //clear out whole_line + whole_line.clear(); + //get program line content const auto & line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); OS_ASSERT(line); - result.push_back(line.get()); + //add programLine to whole_line + whole_line += line.get(); + //get non-default comments if they exist + comment = group->fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, false); + if (comment.is_initialized()) { + //remove space after ! + boost::erase_first(comment.get(), " "); + //add space between end of program line and comment + if (!comment.get().empty()) { + whole_line += " " + comment.get(); + } + } + //add newline character + whole_line += '\n'; + //add whole_line to vector + result.push_back(whole_line); } return result; } diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index e5f28c0bf88..b6ff612f643 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -78,7 +78,6 @@ namespace detail { bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, eMSVariableName); - OS_ASSERT(result); return result; } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index 5db9ec31042..ad9f9d7c0b3 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -21,6 +21,7 @@ #include "ModelFixture.hpp" #include "../EnergyManagementSystemTrendVariable.hpp" +#include "../EnergyManagementSystemGlobalVariable.hpp" #include "../Model_Impl.hpp" #include "../../utilities/idd/IddEnums.hpp" @@ -37,11 +38,16 @@ using std::string; TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) { Model model; - - // add internal variable + + // add global variable + EnergyManagementSystemGlobalVariable globvar("glob var", model); + + // add trend variable EnergyManagementSystemTrendVariable var(model); - var.setEMSVariableName("TestName"); - EXPECT_EQ("TestName", var.eMSVariableName()); + var.setName("TestName"); + EXPECT_EQ("TestName", var.name().get()); + var.setEMSVariableName("glob var"); + EXPECT_EQ("glob var", var.eMSVariableName()); var.setNumberofTimestepstobeLogged(2); EXPECT_EQ(2, var.numberofTimestepstobeLogged()); From 6c0319fa685fecb14fe5815baa94ade2d7e48131 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 8 Sep 2016 12:51:42 -0600 Subject: [PATCH 096/159] enable comments in subroutine fix return flag --- .../model/EnergyManagementSystemProgram.cpp | 3 +- ...yManagementSystemProgramCallingManager.cpp | 3 +- .../EnergyManagementSystemSubroutine.cpp | 106 ++++++++++++++++-- 3 files changed, 103 insertions(+), 9 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index c9f35d59176..7b181cd5940 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -285,7 +285,8 @@ namespace detail { for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - ok.push_back(result); + //ok.push_back(result); + ok.at(i) = result; } //check if all the programs set true result = true; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 73bd05d1789..69280f0156d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -166,7 +166,8 @@ namespace detail { for (auto &program : programs) { WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); - ok.push_back(result); + //ok.push_back(result); + ok.at(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName) = result; } //check if all the programs set true result = true; diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 3eaf853b807..e76867724cc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -76,11 +76,26 @@ namespace detail { // loop through extensible groups and add ProgramLine to body string. std::string body; + boost::optional comment; + auto groups = extensibleGroups(); for (auto group = groups.begin(); group != groups.end(); ++group) { + //get program line content const auto & line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); OS_ASSERT(line); body += line.get(); + //get non-default comments if they exist + comment = group->fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, false); + if (comment.is_initialized()) { + //remove space after ! + boost::erase_first(comment.get(), " "); + //add space between end of program line and comment + if (!comment.get().empty()) { + body += " " + comment.get(); + } + } + //add newline character + body += '\n'; } return body; } @@ -88,6 +103,7 @@ namespace detail { bool EnergyManagementSystemSubroutine_Impl::setBody(const std::string& body) { //set body of program to input string bool result = false; + bool comment_result = false; //if body string empty then return false if (body.empty()) { return false; @@ -105,13 +121,42 @@ namespace detail { //split the body string on newline characters and insert program line for each string line std::vector body_minus_nl = splitString(body_minus_r, '\n'); + std::string body_minus_comment; + std::vector comments; + std::string comment; //add program lines to body std::vector ok(body_minus_nl.size(), false); for (size_t i = 0; i < body_minus_nl.size(); i++) { + //split string on comment character ! + comments = splitString(body_minus_nl.at(i), '!'); + //get extensibleGroup object WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, body_minus_nl.at(i) + '\n'); - ok.push_back(result); + //make sure program line exists and insert + if (comments.size() > 0) { + //remove whitespace at end of comments[0] + boost::trim_right(comments[0]); + //insert program line + result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); + //check if comments exist + if (comments.size() > 1) { + //clear out the old comment + comment.clear(); + //add comment to comment vector + comment.append(comments.at(1)); + //combine any remaining comments for this line into one comment + if (comments.size() > 2) { + for (size_t j = 2; j < comments.size(); j++) { + comment.append("!" + comments.at(j)); + } + } + comment_result = group.setFieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comment); + } + } else { + result = false; + } + //ok.push_back(result); + ok.at(i) = result; } //check if all the programs set true result = true; @@ -138,6 +183,8 @@ namespace detail { bool EnergyManagementSystemSubroutine_Impl::addLine(const std::string& line) { //add line to end of program body bool result = true; + bool comment_result = false; + std::string comment; // remove '\r' from the line string std::string line_rn = line; @@ -145,28 +192,72 @@ namespace detail { while ((pos = line_rn.find("\r", pos)) != std::string::npos) { line_rn.erase(pos, 1); } - // remove '\n' since we add it back in below + // remove '\n' pos = 0; while ((pos = line_rn.find("\n", pos)) != std::string::npos) { line_rn.erase(pos, 1); } - + //get extensibleGroup object WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, line_rn + '\n'); + //split string on comment character ! + std::vector comments = splitString(line_rn, '!'); + //make sure program line exists and insert + if (comments.size() > 0) { + //remove whitespace at end of comments[0] + boost::trim_right(comments[0]); + //insert program line + result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); + //check if comments exist + if (comments.size() > 1) { + //clear out the old comment + comment.clear(); + //add comment to comment vector + comment.append(comments.at(1)); + //combine any remaining comments for this line into one comment + if (comments.size() > 2) { + for (size_t j = 2; j < comments.size(); j++) { + comment.append(", " + comments.at(j)); + } + } + comment_result = group.setFieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comment); + } + } else { + result = false; + } return result; } boost::optional> EnergyManagementSystemSubroutine_Impl::lines() const { //return vector of lines from body std::vector result; + boost::optional comment; + std::string whole_line; // loop through extensible groups and add ProgramLine to vector result. auto groups = extensibleGroups(); for (auto group = groups.begin(); group != groups.end(); ++group) { + //clear out whole_line + whole_line.clear(); + //get program line content const auto & line = group->getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, true); OS_ASSERT(line); - result.push_back(line.get()); + //add programLine to whole_line + whole_line += line.get(); + //get non-default comments if they exist + comment = group->fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, false); + if (comment.is_initialized()) { + //remove space after ! + boost::erase_first(comment.get(), " "); + //add space between end of program line and comment + if (!comment.get().empty()) { + whole_line += " " + comment.get(); + } + } + //add newline character + whole_line += '\n'; + //add whole_line to vector + result.push_back(whole_line); } return result; } @@ -189,7 +280,8 @@ namespace detail { for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - ok.push_back(result); + //ok.push_back(result); + ok.at(i) = result; } //check if all the programs set true result = true; From d7a3aa59f4bfebfd145539efc5b65f3954faef1d Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 9 Sep 2016 10:01:31 -0600 Subject: [PATCH 097/159] forward translator fix for EMS --- .../src/energyplus/ForwardTranslator.cpp | 38 +++++++++---------- .../src/energyplus/ForwardTranslator.hpp | 20 +++++----- ...TranslateEnergyManagementSystemProgram.cpp | 20 ++++++---- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 5178ab18acd..984e3d6089d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1325,50 +1325,50 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb } case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator: { - model::EnergyManagementSystemActuator temp = modelObject.cast(); - retVal = translateEnergyManagementSystemActuator(temp); + model::EnergyManagementSystemActuator actuator = modelObject.cast(); + retVal = translateEnergyManagementSystemActuator(actuator); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable: { - model::EnergyManagementSystemGlobalVariable temp = modelObject.cast(); - retVal = translateEnergyManagementSystemGlobalVariable(temp); + model::EnergyManagementSystemGlobalVariable globalVariable = modelObject.cast(); + retVal = translateEnergyManagementSystemGlobalVariable(globalVariable); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable: { - model::EnergyManagementSystemOutputVariable temp = modelObject.cast(); - retVal = translateEnergyManagementSystemOutputVariable(temp); + model::EnergyManagementSystemOutputVariable outputVariable = modelObject.cast(); + retVal = translateEnergyManagementSystemOutputVariable(outputVariable); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_Program: { - model::EnergyManagementSystemProgram temp = modelObject.cast(); - retVal = EnergyManagementSystemProgram(temp); + model::EnergyManagementSystemProgram program = modelObject.cast(); + retVal = translateEnergyManagementSystemProgram(program); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager: { - model::EnergyManagementSystemProgramCallingManager temp = modelObject.cast(); - retVal = EnergyManagementSystemProgramCallingManager(temp); + model::EnergyManagementSystemProgramCallingManager programCallingManager = modelObject.cast(); + retVal = translateEnergyManagementSystemProgramCallingManager(programCallingManager); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor: { - model::EnergyManagementSystemSensor temp = modelObject.cast(); - retVal = translateEnergyManagementSystemSensor(temp); + model::EnergyManagementSystemSensor sensor = modelObject.cast(); + retVal = translateEnergyManagementSystemSensor(sensor); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_Subroutine: { - model::EnergyManagementSystemSubroutine temp = modelObject.cast(); - retVal = EnergyManagementSystemSubroutine(temp); + model::EnergyManagementSystemSubroutine subroutine = modelObject.cast(); + retVal = translateEnergyManagementSystemSubroutine(subroutine); break; } case openstudio::IddObjectType::OS_EnergyManagementSystem_TrendVariable: { - model::EnergyManagementSystemTrendVariable temp = modelObject.cast(); - retVal = translateEnergyManagementSystemTrendVariable(temp); + model::EnergyManagementSystemTrendVariable trendVariable = modelObject.cast(); + retVal = translateEnergyManagementSystemTrendVariable(trendVariable); break; } case openstudio::IddObjectType::OS_EvaporativeCooler_Direct_ResearchSpecial : @@ -1865,8 +1865,8 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb } case openstudio::IddObjectType::OS_Output_EnergyManagementSystem: { - model::OutputEnergyManagementSystem temp = modelObject.cast(); - retVal = translateOutputEnergyManagementSystem(temp); + model::OutputEnergyManagementSystem outputEnergyManagementSystem = modelObject.cast(); + retVal = translateOutputEnergyManagementSystem(outputEnergyManagementSystem); break; } case openstudio::IddObjectType::OS_People : @@ -2984,13 +2984,13 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_Meter_CustomDecrement); result.push_back(IddObjectType::OS_Output_Variable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); result.push_back(IddObjectType::OS_EnergyManagementSystem_Actuator); result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); result.push_back(IddObjectType::OS_EnergyManagementSystem_Subroutine); result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); result.push_back(IddObjectType::OS_EnergyManagementSystem_OutputVariable); - result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_TrendVariable); result.push_back(IddObjectType::OS_Output_EnergyManagementSystem); diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 616e7213f23..ad24c39df6d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -649,27 +649,27 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateElectricLoadCenterStorageSimple( model::ElectricLoadCenterStorageSimple & modelObject ); - boost::optional translateEnergyManagementSystemActuator(model::EnergyManagementSystemActuator & modelObejct); + boost::optional translateEnergyManagementSystemActuator(model::EnergyManagementSystemActuator & modelObject); - boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObejct ); + boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObject); - boost::optional translateEnergyManagementSystemOutputVariable(model::EnergyManagementSystemOutputVariable & modelObejct ); + boost::optional translateEnergyManagementSystemOutputVariable(model::EnergyManagementSystemOutputVariable & modelObject); - boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObejct); + boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObject); - boost::optional translateEnergyManagementSystemProgramCallingManager(model::EnergyManagementSystemProgramCallingManager & modelObejct); + boost::optional translateEnergyManagementSystemProgramCallingManager(model::EnergyManagementSystemProgramCallingManager & modelObject); - boost::optional translateEnergyManagementSystemSensor(model::EnergyManagementSystemSensor & modelObejct ); + boost::optional translateEnergyManagementSystemSensor(model::EnergyManagementSystemSensor & modelObject); - boost::optional translateEnergyManagementSystemSubroutine(model::EnergyManagementSystemSubroutine & modelObejct ); + boost::optional translateEnergyManagementSystemSubroutine(model::EnergyManagementSystemSubroutine & modelObject); - boost::optional translateEnergyManagementSystemTrendVariable(model::EnergyManagementSystemTrendVariable & modelObejct ); + boost::optional translateEnergyManagementSystemTrendVariable(model::EnergyManagementSystemTrendVariable & modelObject); boost::optional translateEvaporativeFluidCoolerSingleSpeed( model::EvaporativeFluidCoolerSingleSpeed & modelObject ); boost::optional translateEvaporativeFluidCoolerTwoSpeed( model::EvaporativeFluidCoolerTwoSpeed & modelObject ); - boost::optional translateExteriorLights(model::ExteriorLights& modelObject); + boost::optional translateExteriorLights(model::ExteriorLights& modelObject ); boost::optional translateFanConstantVolume( model::FanConstantVolume & modelObject ); @@ -763,7 +763,7 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateOutputVariable( model::OutputVariable & modelObject ); - boost::optional translateOutputEnergyManagementSystem(model::OutputEnergyManagementSystem & modelObejct); + boost::optional translateOutputEnergyManagementSystem(model::OutputEnergyManagementSystem & modelObject ); boost::optional translatePeople( model::People & modelObject ); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index 83b697ad13d..b761d92e9bb 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -31,6 +31,7 @@ #include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include #include #include "../../utilities/idd/IddEnums.hpp" #include @@ -48,20 +49,25 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro { boost::optional s; - //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); - //m_idfObjects.push_back(idfObject); - IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Program,modelObject); + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + m_idfObjects.push_back(idfObject); + m_map.insert(std::make_pair(modelObject.handle(), idfObject)); + //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Program,modelObject); //Name s = modelObject.name(); if (s) { - program.setName(*s); + idfObject.setName(*s); } - //TODO translate UIDs to UID.name in the program for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { - program.pushExtensibleGroup(eg.fields()); + IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); + OptionalString line = eg.getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); + //TODO translate UIDs to UID.name in the program + if (line) { + group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, *line); + } } - return program; + return idfObject; } } // energyplus From 7c1dc8bcd5df1ace4b591d7e161f1fce6032db15 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 12 Sep 2016 14:05:10 -0600 Subject: [PATCH 098/159] trying to replace UIDs with name in translator --- ...TranslateEnergyManagementSystemProgram.cpp | 47 +++++++++++++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 9 ++-- openstudiocore/src/utilities/core/UUID.cpp | 6 +++ openstudiocore/src/utilities/core/UUID.hpp | 4 ++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index b761d92e9bb..c090da0145f 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -30,6 +30,8 @@ #include "../../model/EnergyManagementSystemProgram_Impl.hpp" #include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/core/UUID.hpp" +#include "../../utilities/core/StringHelpers.hpp" #include #include @@ -48,6 +50,8 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemProgram(EnergyManagementSystemProgram & modelObject) { boost::optional s; + boost::smatch matches; + //bool result; IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); m_idfObjects.push_back(idfObject); @@ -59,11 +63,54 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro idfObject.setName(*s); } + std::string a; + std::string b; + std::string c; + std::string aa; + std::string bb; + std::string name; + openstudio::Handle uuids; + QString temp; + //int i; + int found = 0; + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); OptionalString line = eg.getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); //TODO translate UIDs to UID.name in the program if (line) { + //result = boost::regex_search(line.get(), matches, openstudio::uuidInString()); + //boost::sregex_token_iterator iter(line.get().begin(), line.get().end(), openstudio::uuidInString(),0); + + //split string on whitespaces to isolate possible uids + std::vector results = splitString(line.get(), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { + //possible uid so set found to 1 + found = 1; + //remove {} from uid string + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + UUID test = toUUID(results.at(j)); + //std::vector handle = &uid; + Model m = modelObject.model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + name = modelObjects.at(k).nameString(); + uuids = modelObjects.at(k).handle(); + temp = modelObjects.at(k).handle().toString(); + if (modelObjects.at(k).handle() == uid) { + found++; + }; + } + }; + } + } + group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, *line); } } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index a5b876f03e1..2d585ce3d1b 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -273,11 +273,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; //this is what the body should look like with 2 /n's and compare TRUE - std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; //the added lines should compare TRUE to below - std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is !nonsense\n"; + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\n"; std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //set body @@ -293,12 +293,13 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { EXPECT_EQ(line1_test, lines.get()[0]); EXPECT_EQ(line2_test, lines.get()[1]); + model.save(toPath("./EMS_program.osm"), true); + ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); - model.save(toPath("./EMS_program.osm"), true); workspace.save(toPath("./EMS_program.idf"), true); } diff --git a/openstudiocore/src/utilities/core/UUID.cpp b/openstudiocore/src/utilities/core/UUID.cpp index 7186c890f71..2247223abf9 100644 --- a/openstudiocore/src/utilities/core/UUID.cpp +++ b/openstudiocore/src/utilities/core/UUID.cpp @@ -79,6 +79,12 @@ UUID toUUID(const std::string& str) return uuid; } +// Finds Version 4 uuid in a string including {} +boost::regex &uuidInString() { + static boost::regex result("(\\{[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}\\})"); + return result; +} + std::string toString(const UUID& uuid) { return toString(uuid.toString()); diff --git a/openstudiocore/src/utilities/core/UUID.hpp b/openstudiocore/src/utilities/core/UUID.hpp index c0ad548f0d3..e02878bc8d7 100644 --- a/openstudiocore/src/utilities/core/UUID.hpp +++ b/openstudiocore/src/utilities/core/UUID.hpp @@ -21,6 +21,7 @@ #define UTILITIES_CORE_UUID_HPP #include "../UtilitiesAPI.hpp" +#include #include #include @@ -49,6 +50,9 @@ namespace openstudio { /// create a std::string from a UUID UTILITIES_API std::string toString(const UUID& uuid); + /// Find version 4 UUIDs in a string. + UTILITIES_API boost::regex &uuidInString(); + /// create a unique name, prefix << " " << UUID. UTILITIES_API std::string createUniqueName(const std::string& prefix); From dac097663302ab4d05d3502838ab4578679783ec Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 12 Sep 2016 17:44:28 -0600 Subject: [PATCH 099/159] program swaps uids for names --- .../src/energyplus/ForwardTranslator.cpp | 2 +- ...TranslateEnergyManagementSystemProgram.cpp | 33 +++++++++++-------- .../src/energyplus/Test/EMS_GTest.cpp | 6 ++-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 984e3d6089d..283322b0b7a 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -97,7 +97,7 @@ ForwardTranslator::ForwardTranslator() Workspace ForwardTranslator::translateModel( const Model & model, ProgressBar* progressBar ) { - Model modelCopy = model.clone().cast(); + Model modelCopy = model.clone(true).cast(); m_progressBar = progressBar; if (m_progressBar){ diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index c090da0145f..333508c33e2 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -63,16 +63,9 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro idfObject.setName(*s); } - std::string a; - std::string b; - std::string c; - std::string aa; - std::string bb; - std::string name; - openstudio::Handle uuids; - QString temp; - //int i; int found = 0; + UUID prog_uid = modelObject.handle(); + QString prog_uid_string = modelObject.handle().toString(); for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); @@ -100,18 +93,30 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro std::vector modelObjects = m.getModelObjects(); if (modelObjects.size() > 0) { for (size_t k = 0; k < modelObjects.size(); k++) { - name = modelObjects.at(k).nameString(); - uuids = modelObjects.at(k).handle(); - temp = modelObjects.at(k).handle().toString(); + //name = modelObjects.at(k).nameString(); + //uuids = modelObjects.at(k).handle(); + //temp = modelObjects.at(k).handle().toString(); if (modelObjects.at(k).handle() == uid) { found++; + results.at(j) = modelObjects.at(k).nameString(); }; } }; } } - - group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, *line); + std::string final_line; + for (size_t z = 0; z < results.size(); z++) { + final_line += results.at(z) + ' '; + } + if (final_line.back() == ' ') { + boost::erase_last(final_line, " "); + } + group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, final_line); + + } + OptionalString comment = eg.fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); + if (comment) { + group.setFieldComment(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comment.get()); } } return idfObject; diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 2d585ce3d1b..617c3589c9c 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -273,11 +273,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; //this is what the body should look like with 2 /n's and compare TRUE - std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; //the added lines should compare TRUE to below - std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\n"; + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\n"; std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //set body From 250df8f6857fbab72b52dd72c041957e310433f7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 12 Sep 2016 18:23:14 -0600 Subject: [PATCH 100/159] forward translate subroutine uuid swap --- ...TranslateEnergyManagementSystemProgram.cpp | 13 +--- ...nslateEnergyManagementSystemSubroutine.cpp | 61 +++++++++++++++++-- 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index 333508c33e2..dde459a7815 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -50,8 +50,9 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemProgram(EnergyManagementSystemProgram & modelObject) { boost::optional s; - boost::smatch matches; + //boost::smatch matches; //bool result; + int found = 0; IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); m_idfObjects.push_back(idfObject); @@ -62,15 +63,10 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro if (s) { idfObject.setName(*s); } - - int found = 0; - UUID prog_uid = modelObject.handle(); - QString prog_uid_string = modelObject.handle().toString(); for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); OptionalString line = eg.getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); - //TODO translate UIDs to UID.name in the program if (line) { //result = boost::regex_search(line.get(), matches, openstudio::uuidInString()); //boost::sregex_token_iterator iter(line.get().begin(), line.get().end(), openstudio::uuidInString(),0); @@ -85,17 +81,12 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - UUID test = toUUID(results.at(j)); - //std::vector handle = &uid; Model m = modelObject.model(); //TODO cant get below to work so try the harder way //m.getModelObjects(&uid); std::vector modelObjects = m.getModelObjects(); if (modelObjects.size() > 0) { for (size_t k = 0; k < modelObjects.size(); k++) { - //name = modelObjects.at(k).nameString(); - //uuids = modelObjects.at(k).handle(); - //temp = modelObjects.at(k).handle().toString(); if (modelObjects.at(k).handle() == uid) { found++; results.at(j) = modelObjects.at(k).nameString(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp index 85cf0c6fac0..b4aca5fef73 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -30,7 +30,10 @@ #include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" #include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/core/UUID.hpp" +#include "../../utilities/core/StringHelpers.hpp" +#include #include #include "../../utilities/idd/IddEnums.hpp" #include @@ -47,20 +50,66 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemSubroutine(EnergyManagementSystemSubroutine & modelObject) { boost::optional s; + int found = 0; - //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); - //m_idfObjects.push_back(idfObject); - IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine, modelObject); + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + m_idfObjects.push_back(idfObject); + m_map.insert(std::make_pair(modelObject.handle(), idfObject)); + //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine, modelObject); //Name s = modelObject.name(); if (s) { - program.setName(*s); + idfObject.setName(*s); } + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { - program.pushExtensibleGroup(eg.fields()); + IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); + OptionalString line = eg.getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); + if (line) { + //result = boost::regex_search(line.get(), matches, openstudio::uuidInString()); + //boost::sregex_token_iterator iter(line.get().begin(), line.get().end(), openstudio::uuidInString(),0); + + //split string on whitespaces to isolate possible uids + std::vector results = splitString(line.get(), ' '); + for (size_t j = 0; j < results.size(); j++) { + if (results.at(j).size() == 38) { + //possible uid so set found to 1 + found = 1; + //remove {} from uid string + std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + Model m = modelObject.model(); + //TODO cant get below to work so try the harder way + //m.getModelObjects(&uid); + std::vector modelObjects = m.getModelObjects(); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + found++; + results.at(j) = modelObjects.at(k).nameString(); + }; + } + }; + } + } + std::string final_line; + for (size_t z = 0; z < results.size(); z++) { + final_line += results.at(z) + ' '; + } + if (final_line.back() == ' ') { + boost::erase_last(final_line, " "); + } + group.setString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, final_line); + + } + OptionalString comment = eg.fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); + if (comment) { + group.setFieldComment(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comment.get()); + } } - return program; + return idfObject; } } // energyplus From d34f2f7b7dd7d5209238d2ab09117dfd3fd61993 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 13 Sep 2016 13:54:34 -0600 Subject: [PATCH 101/159] subroutine translator debug --- ...nslateEnergyManagementSystemSubroutine.cpp | 2 +- .../src/energyplus/Test/EMS_GTest.cpp | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp index b4aca5fef73..79607b88e34 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -52,7 +52,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSub boost::optional s; int found = 0; - IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine); m_idfObjects.push_back(idfObject); m_map.insert(std::make_pair(modelObject.handle(), idfObject)); //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine, modelObject); diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 617c3589c9c..688348c2d74 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -44,6 +44,8 @@ #include "../../model/EnergyManagementSystemActuator_Impl.hpp" #include "../../model/EnergyManagementSystemProgram.hpp" #include "../../model/EnergyManagementSystemProgram_Impl.hpp" +#include "../../model/EnergyManagementSystemSubroutine.hpp" +#include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" #include "../../model/EnergyManagementSystemProgramCallingManager.hpp" #include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" @@ -303,6 +305,70 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { workspace.save(toPath("./EMS_program.idf"), true); } +TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + + //add program + EnergyManagementSystemSubroutine fan_program_1(model); + std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + boost::optional> lines = fan_program_1.lines(); + EXPECT_EQ(4, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + model.save(toPath("./EMS_subroutine.osm"), true); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); + + workspace.save(toPath("./EMS_subroutine.idf"), true); +} + TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { Model model; From dc23773a6cc9603a0d15d558eb43296799ecb237 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 13 Sep 2016 15:23:32 -0600 Subject: [PATCH 102/159] EMS FT test updates --- .../src/energyplus/Test/EMS_GTest.cpp | 86 +++++++------------ 1 file changed, 31 insertions(+), 55 deletions(-) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 688348c2d74..9d8428704b9 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -66,6 +66,8 @@ #include #include #include +#include +#include #include #include #include @@ -300,7 +302,12 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_ProgramFields::Name, false)); + EXPECT_EQ(programName, object.getString(EnergyManagementSystem_ProgramFields::Name, false).get()); workspace.save(toPath("./EMS_program.idf"), true); } @@ -364,7 +371,12 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program).size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Subroutine).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Subroutine)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_SubroutineFields::Name, false)); + EXPECT_EQ(programName, object.getString(EnergyManagementSystem_SubroutineFields::Name, false).get()); workspace.save(toPath("./EMS_subroutine.idf"), true); } @@ -513,58 +525,19 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { //set program 3 in program 2 slot moving the rest down insert_result = fan_pcm.setProgram(fan_program_3, 1); EXPECT_EQ(true, insert_result); - //now 4 programs - EXPECT_EQ(4, fan_pcm.programs().size()); - //check program name is now program 3's - program = fan_pcm.getProgram(1); - EXPECT_EQ(true, program.is_initialized()); - EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); - //erase program 3 in 2nd slot - bool erase_prog = fan_pcm.eraseProgram(1); - EXPECT_EQ(true, erase_prog); - //check for null programs - std::vector nullProgs = fan_pcm.nullPrograms(); - //should not be any if erasePrograms reindexed correctly - EXPECT_EQ(0, nullProgs.size()); - //check program name is back to program 2's - program = fan_pcm.getProgram(1); - EXPECT_EQ(true, program.is_initialized()); - EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); - - //erase all programs - fan_pcm.erasePrograms(); - //now 0 programs - EXPECT_EQ(0, fan_pcm.programs().size()); - - //create vector of programs - std::vector new_programs; - new_programs.push_back(fan_program_1); - new_programs.push_back(fan_program_2); - new_programs.push_back(fan_program_3); - //set vector of programs - insert_result = fan_pcm.setPrograms(new_programs); - //3 programs - EXPECT_EQ(3, fan_pcm.programs().size()); - //check program name - program = fan_pcm.getProgram(0); - EXPECT_EQ(true, program.is_initialized()); - EXPECT_EQ(fan_program_1.nameString(), program.get().nameString()); - //check program name - program = fan_pcm.getProgram(1); - EXPECT_EQ(true, program.is_initialized()); - EXPECT_EQ(fan_program_2.nameString(), program.get().nameString()); - //check program name - program = fan_pcm.getProgram(2); - EXPECT_EQ(true, program.is_initialized()); - EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); - //EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ProgramCallingManager).size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ProgramCallingManager).size()); - model.save(toPath("./EMS_example.osm"), true); - workspace.save(toPath("./EMS_example.idf"), true); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ProgramCallingManager)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_ProgramCallingManagerFields::Name, false)); + EXPECT_EQ("Best Program Calling Manager", object.getString(EnergyManagementSystem_ProgramCallingManagerFields::Name, false).get()); + + model.save(toPath("./EMS_PCM.osm"), true); + workspace.save(toPath("./EMS_PCM.idf"), true); } TEST_F(EnergyPlusFixture, noForwardTranslatorOutput_EMS) { @@ -586,11 +559,14 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutput_EMS) { ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::Output_EnergyManagementSystem).size()); WorkspaceObject object = workspace.getObjectsByType(IddObjectType::Output_EnergyManagementSystem)[0]; - //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting)); - //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting)); - //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting)); - //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting)); - //ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel)); - //EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel)); + ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting, false)); + EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting, false).get()); + ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting, false)); + EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting, false).get()); + ASSERT_TRUE(object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel, false)); + EXPECT_EQ("None", object.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel, false).get()); + + model.save(toPath("./EMS_output.osm"), true); + workspace.save(toPath("./EMS_output.idf"), true); } \ No newline at end of file From 6207502003151ab02863fe734fcc8761a5cf8be2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 13 Sep 2016 16:21:18 -0600 Subject: [PATCH 103/159] FT GlobalVariable --- ...teEnergyManagementSystemGlobalVariable.cpp | 12 +++----- .../src/energyplus/Test/EMS_GTest.cpp | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp index 59a7e4af0a1..91d30765935 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp @@ -45,22 +45,18 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemGlobalVariable(EnergyManagementSystemGlobalVariable & modelObject) { - //boost::optional d; - //boost::optional m; boost::optional s; IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); m_idfObjects.push_back(idfObject); - //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable, modelObject); + m_map.insert(std::make_pair(modelObject.handle(), idfObject)); - //Name + //AddErlVariable s = modelObject.name(); if (s) { - idfObject.setName(*s); + idfObject.setString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, s.get()); } - //for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { - // program.pushExtensibleGroup(eg.fields()); - //} + return idfObject; } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 9d8428704b9..1c73887250c 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -48,6 +48,8 @@ #include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" #include "../../model/EnergyManagementSystemProgramCallingManager.hpp" #include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -72,6 +74,8 @@ #include #include #include +#include +#include #include #include @@ -569,4 +573,28 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutput_EMS) { model.save(toPath("./EMS_output.osm"), true); workspace.save(toPath("./EMS_output.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorGlobalVariable_EMS) { + Model model; + + // add global variable + EnergyManagementSystemGlobalVariable var("glob var", model); + EXPECT_EQ("glob var", var.nameString()); + + // add global variable + EnergyManagementSystemGlobalVariable var2("glob var 2", model); + EXPECT_EQ("glob var 2", var2.nameString()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(2u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)[0]; + //ASSERT_TRUE(object.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, false)); + //EXPECT_EQ(var.nameString(), object.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, false).get()); + + model.save(toPath("./EMS_GlobalVariable.osm"), true); + workspace.save(toPath("./EMS_GlobalVariable.idf"), true); } \ No newline at end of file From 8dc4bfca7435b5b65be4af7fb657e80ac328cd63 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 13 Sep 2016 16:34:57 -0600 Subject: [PATCH 104/159] FT outputVariable --- .../src/energyplus/Test/EMS_GTest.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 1c73887250c..6a52b761855 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -50,6 +50,8 @@ #include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" #include "../../model/EnergyManagementSystemGlobalVariable.hpp" #include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemOutputVariable.hpp" +#include "../../model/EnergyManagementSystemOutputVariable_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -76,6 +78,8 @@ #include #include #include +#include +#include #include #include @@ -597,4 +601,45 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGlobalVariable_EMS) { model.save(toPath("./EMS_GlobalVariable.osm"), true); workspace.save(toPath("./EMS_GlobalVariable.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { + Model model; + + // add global variable + EnergyManagementSystemGlobalVariable var("glob var", model); + EXPECT_EQ("glob var", var.nameString()); + + // add global variable + EnergyManagementSystemGlobalVariable var2("glob var 2", model); + EXPECT_EQ("glob var 2", var2.nameString()); + + // add output variable + EnergyManagementSystemOutputVariable outvar(model); + //setname + outvar.setName("outputVar"); + EXPECT_EQ("outputVar", outvar.nameString()); + + bool varset = outvar.setEMSVariableName("glob var"); + EXPECT_EQ(true, varset); + + // add output variable + EnergyManagementSystemOutputVariable outvar2(model); + //setname + outvar2.setName("outputVar2"); + EXPECT_EQ("outputVar2", outvar2.nameString()); + + varset = outvar2.setEMSVariableName("glob var 2"); + EXPECT_EQ(true, varset); + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(2u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_OutputVariable).size()); + + //WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_OutputVariable)[0]; + //ASSERT_TRUE(object.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, false)); + //EXPECT_EQ(var.nameString(), object.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, false).get()); + + model.save(toPath("./EMS_OutputVariable.osm"), true); + workspace.save(toPath("./EMS_OutputVariable.idf"), true); } \ No newline at end of file From c8eada605e94b85d6e2de4f4e2f358aa30d33e83 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 14 Sep 2016 10:03:25 -0600 Subject: [PATCH 105/159] FT trendvariable --- ...teEnergyManagementSystemGlobalVariable.cpp | 2 +- .../src/energyplus/Test/EMS_GTest.cpp | 34 +++++++++++++++++++ .../EnergyManagementSystemOutputVariable.cpp | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp index 91d30765935..0d8f9129ef7 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp @@ -46,7 +46,7 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemGlobalVariable(EnergyManagementSystemGlobalVariable & modelObject) { boost::optional s; - + //TODO add all the global variables to one object in the IDF IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); m_idfObjects.push_back(idfObject); m_map.insert(std::make_pair(modelObject.handle(), idfObject)); diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 6a52b761855..5595046e883 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -52,6 +52,8 @@ #include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" #include "../../model/EnergyManagementSystemOutputVariable.hpp" #include "../../model/EnergyManagementSystemOutputVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemTrendVariable.hpp" +#include "../../model/EnergyManagementSystemTrendVariable_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -80,6 +82,8 @@ #include #include #include +#include +#include #include #include @@ -642,4 +646,34 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { model.save(toPath("./EMS_OutputVariable.osm"), true); workspace.save(toPath("./EMS_OutputVariable.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { + Model model; + + // add global variable + EnergyManagementSystemGlobalVariable globvar("glob var", model); + + // add trend variable + EnergyManagementSystemTrendVariable var(model); + var.setName("TestName"); + EXPECT_EQ("TestName", var.name().get()); + var.setEMSVariableName("glob var"); + EXPECT_EQ("glob var", var.eMSVariableName()); + + var.setNumberofTimestepstobeLogged(2); + EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_TrendVariable).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_TrendVariable)[0]; + ASSERT_TRUE(object.getString(EnergyManagementSystem_TrendVariableFields::EMSVariableName, false)); + EXPECT_EQ(globvar.nameString(), object.getString(EnergyManagementSystem_TrendVariableFields::EMSVariableName, false).get()); + ASSERT_TRUE(object.getDouble(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, false)); + EXPECT_EQ(2, object.getDouble(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, false).get()); + + model.save(toPath("./EMS_TrendVariable.osm"), true); + workspace.save(toPath("./EMS_TrendVariable.idf"), true); } \ No newline at end of file diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 76c881a9e7b..778e91b3d4c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -132,6 +132,8 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); } IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { From a07d282b31be1d17f4fba6b65aadc7862cf9db41 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 15 Sep 2016 13:41:11 -0600 Subject: [PATCH 106/159] setName ' ' to '_' --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ForwardTranslator.cpp | 7 ++ .../src/energyplus/ForwardTranslator.hpp | 3 + ...EnergyManagementSystemInternalVariable.cpp | 72 +++++++++++++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 55 ++++++++++---- ...gyManagementSystemGlobalVariable_GTest.cpp | 2 +- ...gyManagementSystemOutputVariable_GTest.cpp | 4 +- .../EnergyManagementSystemProgram_GTest.cpp | 44 +++++++++--- .../EnergyManagementSystemSensor_GTest.cpp | 6 +- ...EnergyManagementSystemSubroutine_GTest.cpp | 17 ++--- ...rgyManagementSystemTrendVariable_GTest.cpp | 4 +- .../src/utilities/idf/IdfObject.cpp | 31 ++++++++ 12 files changed, 207 insertions(+), 39 deletions(-) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index c9d3b178a49..f13eaa1abfa 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -121,6 +121,7 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 283322b0b7a..00df36e670b 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1335,6 +1335,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemGlobalVariable(globalVariable); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_InternalVariable: + { + model::EnergyManagementSystemInternalVariable internalVariable = modelObject.cast(); + retVal = translateEnergyManagementSystemInternalVariable(internalVariable); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable: { model::EnergyManagementSystemOutputVariable outputVariable = modelObject.cast(); @@ -2985,6 +2991,7 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_Output_Variable); result.push_back(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_InternalVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); result.push_back(IddObjectType::OS_EnergyManagementSystem_Actuator); result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index ad24c39df6d..55be9603212 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -145,6 +145,7 @@ class ElectricLoadCenterInverterSimple; class ElectricLoadCenterStorageSimple; class EnergyManagementSystemActuator; class EnergyManagementSystemGlobalVariable; +class EnergyManagementSystemInternalVariable; class EnergyManagementSystemOutputVariable; class EnergyManagementSystemProgram; class EnergyManagementSystemProgramCallingManager; @@ -653,6 +654,8 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObject); + boost::optional translateEnergyManagementSystemInternalVariable(model::EnergyManagementSystemInternalVariable & modelObject); + boost::optional translateEnergyManagementSystemOutputVariable(model::EnergyManagementSystemOutputVariable & modelObject); boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObject); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp new file mode 100644 index 00000000000..c7550628d79 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp @@ -0,0 +1,72 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemInternalVariable.hpp" +#include "../../model/EnergyManagementSystemInternalVariable_Impl.hpp" + + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemInternalVariable(EnergyManagementSystemInternalVariable & modelObject) +{ + boost::optional i; + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_InternalVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + s = modelObject.internalDataIndexKeyName(); + if (s) { + idfObject.setString(EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, s.get()); + } + s = modelObject.internalDataType(); + if (s) { + idfObject.setString(EnergyManagementSystem_InternalVariableFields::InternalDataType, s.get()); + } + + return idfObject; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 5595046e883..1dd27d53838 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -54,6 +54,8 @@ #include "../../model/EnergyManagementSystemOutputVariable_Impl.hpp" #include "../../model/EnergyManagementSystemTrendVariable.hpp" #include "../../model/EnergyManagementSystemTrendVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemInternalVariable.hpp" +#include "../../model/EnergyManagementSystemInternalVariable_Impl.hpp" #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -84,6 +86,8 @@ #include #include #include +#include +#include #include #include @@ -128,7 +132,7 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Variable)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); - EXPECT_EQ("OATdb Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + EXPECT_EQ("OATdb_Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); @@ -165,7 +169,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Variable)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); - EXPECT_EQ("Light Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + EXPECT_EQ("Light_Sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); EXPECT_EQ(zone1.name().get(), object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); @@ -203,7 +207,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Output_Meter)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Name, false)); - EXPECT_EQ("meter sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); + EXPECT_EQ("meter_sensor", object.getString(EnergyManagementSystem_SensorFields::Name, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false)); EXPECT_EQ("", object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, false)); @@ -243,7 +247,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { WorkspaceObject outvar = workspace.getObjectsByType(IddObjectType::Fan_ConstantVolume)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::Name, false)); - EXPECT_EQ(fanName, object.getString(EnergyManagementSystem_ActuatorFields::Name, false).get()); + EXPECT_EQ("Fan_Constant_Volume_1Press_Actuator", object.getString(EnergyManagementSystem_ActuatorFields::Name, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false)); EXPECT_EQ(fan.name().get(), object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false).get()); ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false)); @@ -319,7 +323,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Program)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_ProgramFields::Name, false)); - EXPECT_EQ(programName, object.getString(EnergyManagementSystem_ProgramFields::Name, false).get()); + EXPECT_EQ("Fan_Constant_Volume_1Pressure_Rise_Program_by_Body", object.getString(EnergyManagementSystem_ProgramFields::Name, false).get()); workspace.save(toPath("./EMS_program.idf"), true); } @@ -388,7 +392,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Subroutine)[0]; ASSERT_TRUE(object.getString(EnergyManagementSystem_SubroutineFields::Name, false)); - EXPECT_EQ(programName, object.getString(EnergyManagementSystem_SubroutineFields::Name, false).get()); + EXPECT_EQ("Fan_Constant_Volume_1Pressure_Rise_Program_by_Body", object.getString(EnergyManagementSystem_SubroutineFields::Name, false).get()); workspace.save(toPath("./EMS_subroutine.idf"), true); } @@ -588,11 +592,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGlobalVariable_EMS) { // add global variable EnergyManagementSystemGlobalVariable var("glob var", model); - EXPECT_EQ("glob var", var.nameString()); + EXPECT_EQ("glob_var", var.nameString()); // add global variable EnergyManagementSystemGlobalVariable var2("glob var 2", model); - EXPECT_EQ("glob var 2", var2.nameString()); + EXPECT_EQ("glob_var_2", var2.nameString()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -612,11 +616,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { // add global variable EnergyManagementSystemGlobalVariable var("glob var", model); - EXPECT_EQ("glob var", var.nameString()); + EXPECT_EQ("glob_var", var.nameString()); // add global variable EnergyManagementSystemGlobalVariable var2("glob var 2", model); - EXPECT_EQ("glob var 2", var2.nameString()); + EXPECT_EQ("glob_var_2", var2.nameString()); // add output variable EnergyManagementSystemOutputVariable outvar(model); @@ -624,7 +628,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { outvar.setName("outputVar"); EXPECT_EQ("outputVar", outvar.nameString()); - bool varset = outvar.setEMSVariableName("glob var"); + bool varset = outvar.setEMSVariableName("glob_var"); EXPECT_EQ(true, varset); // add output variable @@ -633,7 +637,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { outvar2.setName("outputVar2"); EXPECT_EQ("outputVar2", outvar2.nameString()); - varset = outvar2.setEMSVariableName("glob var 2"); + varset = outvar2.setEMSVariableName("glob_var_2"); EXPECT_EQ(true, varset); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -658,8 +662,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { EnergyManagementSystemTrendVariable var(model); var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); - var.setEMSVariableName("glob var"); - EXPECT_EQ("glob var", var.eMSVariableName()); + var.setEMSVariableName("glob_var"); + EXPECT_EQ("glob_var", var.eMSVariableName()); var.setNumberofTimestepstobeLogged(2); EXPECT_EQ(2, var.numberofTimestepstobeLogged()); @@ -676,4 +680,27 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { model.save(toPath("./EMS_TrendVariable.osm"), true); workspace.save(toPath("./EMS_TrendVariable.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorInternalVariable_EMS) { + Model model; + + // add internal variable + EnergyManagementSystemInternalVariable var(model); + var.setName("Test name"); + var.setInternalDataIndexKeyName("TestName"); + var.setInternalDataType("TestName"); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_InternalVariable).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_InternalVariable)[0]; + ASSERT_TRUE(object.getString(EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, false)); + EXPECT_EQ("TestName", object.getString(EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_InternalVariableFields::InternalDataType, false)); + EXPECT_EQ("TestName", object.getString(EnergyManagementSystem_InternalVariableFields::InternalDataType, false).get()); + + model.save(toPath("./EMS_InternalVariable.osm"), true); + workspace.save(toPath("./EMS_InternalVariable.idf"), true); } \ No newline at end of file diff --git a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp index db56b3a6748..6fee9bb70f8 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp @@ -40,6 +40,6 @@ TEST_F(ModelFixture, EMSGlobalVariable_EMSGlobalVariable) // add global variable EnergyManagementSystemGlobalVariable var("glob var", model); - EXPECT_EQ("glob var", var.nameString()); + EXPECT_EQ("glob_var", var.nameString()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 3c33b2dbc69..0359eafa420 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -122,9 +122,9 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) // add program EnergyManagementSystemProgram program(model); program.setName("program 1"); - setprogram = outvar.setEMSProgramorSubroutineName("program 1"); + setprogram = outvar.setEMSProgramorSubroutineName("program_1"); EXPECT_EQ(true, setprogram); - EXPECT_EQ("program 1", outvar.eMSProgramorSubroutineName().get()); + EXPECT_EQ("program_1", outvar.eMSProgramorSubroutineName().get()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 51cfbbaef5c..1fc50145718 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -65,10 +65,11 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); + fan.setName("fan"); //add actuator on fan EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; + std::string fanName = fan.name().get() + "Pressure_Actuator"; fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); @@ -77,7 +78,7 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) //add program EnergyManagementSystemProgram fan_program_1(model); - std::string programName = fan.name().get() + "Pressure Rise Program by Body"; + std::string programName = fan.name().get() + "Pressure_Rise_Program_by_Body"; fan_program_1.setName(programName); //this body has /r/n in it std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; @@ -101,15 +102,15 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_1.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); fanActuator.remove(); EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); //add actuator on fan again EnergyManagementSystemActuator fanActuator2(fan); - fanName = fan.name().get() + "Press Actuator"; + fanName = fan.name().get() + "Press_Actuator"; fanActuator2.setName(fanName); fanControlType = "Fan Pressure Rise"; fanActuator2.setActuatedComponentControlType(fanControlType); @@ -142,8 +143,8 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_2.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); OATdbSensor.remove(); EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); @@ -182,8 +183,8 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_3.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); OATdbSensor2.remove(); EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); @@ -202,3 +203,28 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) } +TEST_F(ModelFixture, EMSProgram_EMSProgram2) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + //add program + EnergyManagementSystemProgram program_1(model); + std::string programName = "program one"; + program_1.setName(programName); + EXPECT_EQ("program one", program_1.nameString()); + EnergyManagementSystemProgram program_2(model); + program_2.setName(programName); + EXPECT_EQ("program one_1", program_2.nameString()); + EnergyManagementSystemProgram program_3(model); + program_3.setName(programName); + EXPECT_EQ("program one_1", program_3.nameString()); + EnergyManagementSystemProgram program_4(model); + program_4.setName("program one"); + EXPECT_EQ("program one_1", program_4.nameString()); + +} + diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 6e950c5d086..bcf2c3a8377 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -60,7 +60,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) OATdbSensor.setName("OATdb Sensor"); OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); - EXPECT_EQ("OATdb Sensor", OATdbSensor.nameString()); + EXPECT_EQ("OATdb_Sensor", OATdbSensor.nameString()); EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle() ); EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); EXPECT_EQ("", OATdbSensor.keyName().get()); @@ -77,7 +77,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) lights.setKeyName(zone1.name().get()); EXPECT_EQ(zone1.name().get(), lights.keyName().get()); - EXPECT_EQ("Light Sensor", lights.nameString()); + EXPECT_EQ("Light_Sensor", lights.nameString()); // create meter OutputMeter meter(model); @@ -88,7 +88,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) meter_sensor.setName("meter sensor"); meter_sensor.setOutputMeter(meter); - EXPECT_EQ("meter sensor", meter_sensor.nameString()); + EXPECT_EQ("meter_sensor", meter_sensor.nameString()); EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); EXPECT_EQ(meter, meter_sensor.outputMeter()); EXPECT_EQ("", meter_sensor.keyName().get()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp index cc07630d301..c7171196c5e 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp @@ -66,10 +66,11 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); + fan.setName("fan"); //add actuator on fan EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; + std::string fanName = fan.name().get() + "Press_Actuator"; fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); @@ -102,15 +103,15 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_1.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_1.invalidReferencedObjects().size()); fanActuator.remove(); EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); //add actuator on fan again EnergyManagementSystemActuator fanActuator2(fan); - fanName = fan.name().get() + "Press Actuator"; + fanName = fan.name().get() + "Press_Actuator"; fanActuator2.setName(fanName); fanControlType = "Fan Pressure Rise"; fanActuator2.setActuatedComponentControlType(fanControlType); @@ -143,8 +144,8 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_2.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[0].nameString() == fanName) || (fan_program_2.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_2.referencedObjects()[1].nameString() == fanName) || (fan_program_2.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_2.invalidReferencedObjects().size()); OATdbSensor.remove(); EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); @@ -183,8 +184,8 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) EXPECT_EQ(line2_test, lines.get()[1]); EXPECT_EQ(2, fan_program_3.referencedObjects().size()); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb Sensor")); - EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[0].nameString() == fanName) || (fan_program_3.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_3.referencedObjects()[1].nameString() == fanName) || (fan_program_3.referencedObjects()[1].nameString() == "OATdb_Sensor")); EXPECT_EQ(0, fan_program_3.invalidReferencedObjects().size()); OATdbSensor2.remove(); EXPECT_EQ(1, fan_program_3.invalidReferencedObjects().size()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index ad9f9d7c0b3..0ac81c93610 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -46,8 +46,8 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) EnergyManagementSystemTrendVariable var(model); var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); - var.setEMSVariableName("glob var"); - EXPECT_EQ("glob var", var.eMSVariableName()); + var.setEMSVariableName("glob_var"); + EXPECT_EQ("glob_var", var.eMSVariableName()); var.setNumberofTimestepstobeLogged(2); EXPECT_EQ(2, var.numberofTimestepstobeLogged()); diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index 39a5f1162c5..a8438fcc715 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -422,6 +422,37 @@ namespace detail { { std::string newName = encodeString(_newName); + switch (m_iddObject.type().value()) { + // get all EMS idd object types in both E+ and OS IDD + case openstudio::IddObjectType::EnergyManagementSystem_Actuator:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through + //case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped + //case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through + //case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped + //case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_InternalVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Program:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Program:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Sensor:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Subroutine:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Subroutine:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_TrendVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_TrendVariable:; // deliberate fall through + // replace ‘ ‘ with ‘_’ + std::replace(newName.begin(), newName.end(), ' ', '_'); + break; + //case openstudio::IddObjectType::EnergyManagementSystem_OutputVariable:; // deliberate fall through + //case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable:; // deliberate fall through + //Enforce Title-Case + default: + // no-op + break; + } + // check Idd to see if this object has a name if (OptionalUnsigned index = m_iddObject.nameFieldIndex()) { // if so, change the name, or create it From 9dfedb36e38a63048473e8bb5fed1581028fe9ef Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 09:32:00 -0600 Subject: [PATCH 107/159] naming stuff --- .../EnergyManagementSystemProgram_GTest.cpp | 14 +++++----- .../src/utilities/idf/IdfObject.cpp | 28 +++++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 1fc50145718..b24abadbd0d 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -206,25 +206,25 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) TEST_F(ModelFixture, EMSProgram_EMSProgram2) { Model model; - Building building = model.getUniqueModelObject(); + //Building building = model.getUniqueModelObject(); - ThermalZone zone1(model); - ThermalZone zone2(model); + //ThermalZone zone1(model); + //ThermalZone zone2(model); //add program EnergyManagementSystemProgram program_1(model); std::string programName = "program one"; program_1.setName(programName); - EXPECT_EQ("program one", program_1.nameString()); + EXPECT_EQ("program_one", program_1.nameString()); EnergyManagementSystemProgram program_2(model); program_2.setName(programName); - EXPECT_EQ("program one_1", program_2.nameString()); + EXPECT_EQ("program_one_1", program_2.nameString()); EnergyManagementSystemProgram program_3(model); program_3.setName(programName); - EXPECT_EQ("program one_1", program_3.nameString()); + EXPECT_EQ("program_one_2", program_3.nameString()); EnergyManagementSystemProgram program_4(model); program_4.setName("program one"); - EXPECT_EQ("program one_1", program_4.nameString()); + EXPECT_EQ("program_one_3", program_4.nameString()); } diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index a8438fcc715..b71b9c70442 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -468,13 +468,37 @@ namespace detail { if (i < n) { std::string oldName = m_fields[i]; m_fields[i] = newName; - m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); + //std::size_t found; + //switch (m_iddObject.type().value()) { + //case openstudio::IddObjectType::EnergyManagementSystem_Program:; // deliberate fall through + //case openstudio::IddObjectType::OS_EnergyManagementSystem_Program:; // deliberate fall through + // //check if last is _# + // + // found = newName.find_last_of("_"); + // if (found + 1 < newName.npos) { + // std::string poss_num = newName.substr(found + 1, newName.npos); + // std::string::const_iterator it = poss_num.begin(); + // while (it != poss_num.end() && std::isdigit(*it)) ++it; + // bool temp = !poss_num.empty() && it == poss_num.end(); + // if (temp) { + // //std::replace(newName.begin(), newName.end(), '_', ' '); + // m_diffs.push_back(IdfObjectDiff(i, oldName, _newName)); + // break; + // } + // } + // m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); + // break; + //default: + m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); + // break; + //} } else { m_fields.push_back(newName); m_diffs.push_back(IdfObjectDiff(i, boost::none, newName)); } - return _newName; // success! + //TODO should this be newName or _nameName?? -BLB + return newName; // success! } return boost::none; // no name } From 87786b3576bf0367e2c690ecd0faae43ade30bb7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 11:27:05 -0600 Subject: [PATCH 108/159] MAdams name change --- .../EnergyManagementSystemProgram_GTest.cpp | 7 ++-- .../src/utilities/idf/IdfObject.cpp | 34 +++---------------- .../src/utilities/idf/Workspace.cpp | 6 ++++ 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index b24abadbd0d..de87f9c0d9d 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -206,10 +206,10 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) TEST_F(ModelFixture, EMSProgram_EMSProgram2) { Model model; - //Building building = model.getUniqueModelObject(); + Building building = model.getUniqueModelObject(); - //ThermalZone zone1(model); - //ThermalZone zone2(model); + ThermalZone zone1(model); + ThermalZone zone2(model); //add program EnergyManagementSystemProgram program_1(model); @@ -226,5 +226,6 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { program_4.setName("program one"); EXPECT_EQ("program_one_3", program_4.nameString()); + model.save(toPath("./EMS_nametest.osm"), true); } diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index b71b9c70442..a97e8896e0b 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -423,13 +423,13 @@ namespace detail { std::string newName = encodeString(_newName); switch (m_iddObject.type().value()) { - // get all EMS idd object types in both E+ and OS IDD + // get all EMS idd object types in both E+ and OS IDD case openstudio::IddObjectType::EnergyManagementSystem_Actuator:; // deliberate fall through case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through //case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped //case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through - //case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped - //case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through + //case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped + //case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable:; // deliberate fall through @@ -447,7 +447,7 @@ namespace detail { break; //case openstudio::IddObjectType::EnergyManagementSystem_OutputVariable:; // deliberate fall through //case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable:; // deliberate fall through - //Enforce Title-Case + //TODO Enforce Title-Case default: // no-op break; @@ -468,36 +468,12 @@ namespace detail { if (i < n) { std::string oldName = m_fields[i]; m_fields[i] = newName; - //std::size_t found; - //switch (m_iddObject.type().value()) { - //case openstudio::IddObjectType::EnergyManagementSystem_Program:; // deliberate fall through - //case openstudio::IddObjectType::OS_EnergyManagementSystem_Program:; // deliberate fall through - // //check if last is _# - // - // found = newName.find_last_of("_"); - // if (found + 1 < newName.npos) { - // std::string poss_num = newName.substr(found + 1, newName.npos); - // std::string::const_iterator it = poss_num.begin(); - // while (it != poss_num.end() && std::isdigit(*it)) ++it; - // bool temp = !poss_num.empty() && it == poss_num.end(); - // if (temp) { - // //std::replace(newName.begin(), newName.end(), '_', ' '); - // m_diffs.push_back(IdfObjectDiff(i, oldName, _newName)); - // break; - // } - // } - // m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); - // break; - //default: - m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); - // break; - //} + m_diffs.push_back(IdfObjectDiff(i, oldName, newName)); } else { m_fields.push_back(newName); m_diffs.push_back(IdfObjectDiff(i, boost::none, newName)); } - //TODO should this be newName or _nameName?? -BLB return newName; // success! } return boost::none; // no name diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 769340a1c24..99a7a80d658 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1916,6 +1916,9 @@ namespace detail { boost::optional Workspace_Impl::getNameSuffix(const std::string& objectName) const { std::size_t found = objectName.find_last_of(' '); + if (found == string::npos) { + found = objectName.find_last_of('_'); + } if ( found != string::npos ) { std::string strSuffix = objectName.substr(found+1); const char *p = strSuffix.c_str(); @@ -1933,6 +1936,9 @@ namespace detail { std::string Workspace_Impl::getBaseName(const std::string& objectName) const { std::size_t found = objectName.find_last_of(' '); + if (found == string::npos) { + found = objectName.find_last_of('_'); + } if ( found != string::npos ) { std::string strSuffix = objectName.substr(found+1); const char *p = strSuffix.c_str(); From 849b49181116b891d2824379be5701c9037e1119 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 13:44:08 -0600 Subject: [PATCH 109/159] Dan method --- .../EnergyManagementSystemProgram_GTest.cpp | 14 +++++++ .../src/utilities/idf/Workspace.cpp | 42 +++++++++++++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index de87f9c0d9d..8857abeab24 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -209,7 +209,11 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { Building building = model.getUniqueModelObject(); ThermalZone zone1(model); + zone1.setName("Name With Space_1"); ThermalZone zone2(model); + zone2.setName("Name With Space_1"); + ThermalZone zone3(model); + zone3.setName("Name With Space_1"); //add program EnergyManagementSystemProgram program_1(model); @@ -226,6 +230,16 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { program_4.setName("program one"); EXPECT_EQ("program_one_3", program_4.nameString()); + EnergyManagementSystemProgram program_4a(model); + program_4a.setName("program one_1"); + EXPECT_EQ("program_one_4", program_4a.nameString()); + + EnergyManagementSystemProgram program_5(model); + program_5.setName("name one_1"); + EXPECT_EQ("name_one_1", program_5.nameString()); + EnergyManagementSystemProgram program_6(model); + program_6.setName("name one_1"); + EXPECT_EQ("name_one_2", program_6.nameString()); model.save(toPath("./EMS_nametest.osm"), true); } diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 99a7a80d658..5ba9b8a2445 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1915,10 +1915,23 @@ namespace detail { } boost::optional Workspace_Impl::getNameSuffix(const std::string& objectName) const { - std::size_t found = objectName.find_last_of(' '); - if (found == string::npos) { - found = objectName.find_last_of('_'); - } + //Mark method + //std::size_t found = objectName.find_last_of(' '); + //if (found == string::npos) { + // found = objectName.find_last_of('_'); + //} + //Dan method + std::size_t found1 = objectName.find_last_of(' '); + std::size_t found2 = objectName.find_last_of('_'); + std::size_t found = string::npos; + if (found1 != string::npos && found2 != string::npos) { + found = std::max(found1, found2); + } else if (found1 != string::npos) { + found = found1; + } else if (found2 != string::npos) { + found = found2; + } + if ( found != string::npos ) { std::string strSuffix = objectName.substr(found+1); const char *p = strSuffix.c_str(); @@ -1935,10 +1948,23 @@ namespace detail { } std::string Workspace_Impl::getBaseName(const std::string& objectName) const { - std::size_t found = objectName.find_last_of(' '); - if (found == string::npos) { - found = objectName.find_last_of('_'); - } + //Mark method + //std::size_t found = objectName.find_last_of(' '); + //if (found == string::npos) { + // found = objectName.find_last_of('_'); + //} + //Dan method + std::size_t found1 = objectName.find_last_of(' '); + std::size_t found2 = objectName.find_last_of('_'); + std::size_t found = string::npos; + if (found1 != string::npos && found2 != string::npos) { + found = std::max(found1, found2); + } else if (found1 != string::npos) { + found = found1; + } else if (found2 != string::npos) { + found = found2; + } + if ( found != string::npos ) { std::string strSuffix = objectName.substr(found+1); const char *p = strSuffix.c_str(); From 15fc86f4d703412e9b177c6af382ea207ea0d5de Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 17:17:41 -0600 Subject: [PATCH 110/159] Name with " " or "_" --- .../src/utilities/idf/Workspace.cpp | 27 ++++++++++++++----- .../src/utilities/idf/Workspace_Impl.hpp | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 5ba9b8a2445..2f684d5e590 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1914,22 +1914,29 @@ namespace detail { return istringEqual(baseName, getBaseName(objectName)); } - boost::optional Workspace_Impl::getNameSuffix(const std::string& objectName) const { + std::tuple, std::string> Workspace_Impl::getNameSuffix(const std::string& objectName) const { //Mark method //std::size_t found = objectName.find_last_of(' '); //if (found == string::npos) { // found = objectName.find_last_of('_'); //} //Dan method + std::size_t found1 = objectName.find_last_of(' '); std::size_t found2 = objectName.find_last_of('_'); std::size_t found = string::npos; + std::string spacer = " "; if (found1 != string::npos && found2 != string::npos) { found = std::max(found1, found2); + if (found2 > found1) { + spacer = "_"; + } } else if (found1 != string::npos) { found = found1; + spacer = " "; } else if (found2 != string::npos) { found = found2; + spacer = "_"; } if ( found != string::npos ) { @@ -1942,9 +1949,9 @@ namespace detail { ++p; ++count; } - if (suffix > 0 && count == strSuffix.size() ) { return suffix; } + if (suffix > 0 && count == strSuffix.size() ) { return std::make_tuple(suffix, spacer); } } - return boost::none; + return std::make_tuple(boost::none, spacer); } std::string Workspace_Impl::getBaseName(const std::string& objectName) const { @@ -1954,6 +1961,7 @@ namespace detail { // found = objectName.find_last_of('_'); //} //Dan method + std::size_t found1 = objectName.find_last_of(' '); std::size_t found2 = objectName.find_last_of('_'); std::size_t found = string::npos; @@ -2540,9 +2548,11 @@ namespace detail { bool fillIn) const { vector takenValues; + std::tuple, std::string> takenSuffix; for (const WorkspaceObject& object : objectsInTheSeries) { - if (boost::optional takenSuffix = getNameSuffix(*(object.name()))) { - takenValues.push_back(*takenSuffix); + takenSuffix = getNameSuffix(*(object.name())); + if (std::get<0>(takenSuffix)) { + takenValues.push_back(*std::get<0>(takenSuffix)); } } std::sort(takenValues.begin(), takenValues.end()); @@ -2564,8 +2574,11 @@ namespace detail { suffix = *(takenValues.rbegin()) + 1; } } - - return getBaseName(objectName) + ' ' + boost::lexical_cast(suffix); + std::string spacer = std::get<1>(takenSuffix); + if (spacer == "") { + spacer = " "; + } + return getBaseName(objectName) + spacer + boost::lexical_cast(suffix); } std::vector< std::vector > Workspace_Impl::nameConflicts( diff --git a/openstudiocore/src/utilities/idf/Workspace_Impl.hpp b/openstudiocore/src/utilities/idf/Workspace_Impl.hpp index d78744e9236..97cfa6e93a9 100644 --- a/openstudiocore/src/utilities/idf/Workspace_Impl.hpp +++ b/openstudiocore/src/utilities/idf/Workspace_Impl.hpp @@ -518,7 +518,7 @@ namespace detail { bool baseNamesMatch(const std::string& baseName, const std::string& objectName) const; /** Returns optional suffix integer from objectName. */ - boost::optional getNameSuffix(const std::string& objectName) const; + std::tuple, std::string> getNameSuffix(const std::string& objectName) const; /** Returns objectName in with any suffix integers removed. */ std::string getBaseName(const std::string& objectName) const; From 2ccf51af8c3a589c0177ef4f651fc663db3da345 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 18:28:09 -0600 Subject: [PATCH 111/159] name fix --- .../src/model/test/EnergyManagementSystemProgram_GTest.cpp | 3 +++ openstudiocore/src/utilities/idf/Workspace.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 8857abeab24..1cde2d14ca5 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -210,10 +210,13 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { ThermalZone zone1(model); zone1.setName("Name With Space_1"); + EXPECT_EQ("Name With Space_1", zone1.nameString()); ThermalZone zone2(model); zone2.setName("Name With Space_1"); + EXPECT_EQ("Name With Space_2", zone2.nameString()); ThermalZone zone3(model); zone3.setName("Name With Space_1"); + EXPECT_EQ("Name With Space_3", zone3.nameString()); //add program EnergyManagementSystemProgram program_1(model); diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 2f684d5e590..7a4ec1742f6 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1951,7 +1951,7 @@ namespace detail { } if (suffix > 0 && count == strSuffix.size() ) { return std::make_tuple(suffix, spacer); } } - return std::make_tuple(boost::none, spacer); + return std::make_tuple(boost::none, " "); } std::string Workspace_Impl::getBaseName(const std::string& objectName) const { @@ -2578,6 +2578,8 @@ namespace detail { if (spacer == "") { spacer = " "; } + std::string temp = getBaseName(objectName); + std::string temp2 = spacer; return getBaseName(objectName) + spacer + boost::lexical_cast(suffix); } From b6513213ad449a981aeb5f3a9197d2d3c42ac0cf Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 16 Sep 2016 19:17:07 -0600 Subject: [PATCH 112/159] clean up --- openstudiocore/src/utilities/idf/Workspace.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 7a4ec1742f6..f9b36b7233e 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -2578,8 +2578,6 @@ namespace detail { if (spacer == "") { spacer = " "; } - std::string temp = getBaseName(objectName); - std::string temp2 = spacer; return getBaseName(objectName) + spacer + boost::lexical_cast(suffix); } From 458f40b2b66d151c6f7903314c5bd4954417eb41 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 19 Sep 2016 10:34:52 -0600 Subject: [PATCH 113/159] add EMS ConstructionIndexVariable to Model --- openstudiocore/src/model/CMakeLists.txt | 1 + ...agementSystemConstructionIndexVariable.cpp | 8 +- ...agementSystemConstructionIndexVariable.hpp | 2 - ...ntSystemConstructionIndexVariable_Impl.hpp | 2 - ...tSystemConstructionIndexVariable_GTest.cpp | 94 +++++++++++++++++++ .../src/utilities/idf/IdfObject.cpp | 4 +- 6 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index aba9a60837d..bba13991ce4 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1640,6 +1640,7 @@ set(${target_name}_test_src test/ElectricLoadCenterInverterLookUpTable_GTest.cpp test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp + test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp test/EnergyManagementSystemGlobalVariable_GTest.cpp test/EnergyManagementSystemInternalVariable_GTest.cpp test/EnergyManagementSystemOutputVariable_GTest.cpp diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp index 186b017bf77..d3d97b72051 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -71,7 +71,7 @@ namespace detail { ModelObject EnergyManagementSystemConstructionIndexVariable_Impl::constructionObject() const { boost::optional value = optionalConstructionObject(); if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Construction Object attached."); + LOG(Info, " does not have an Construction Object attached."); } return value.get(); } @@ -91,12 +91,6 @@ EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstruct : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // OS_EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName - bool ok = true; - // ok = setConstructionObject(); - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemConstructionIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp index 4fb3f54daee..9b3dc27efd8 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp @@ -52,14 +52,12 @@ class MODEL_API EnergyManagementSystemConstructionIndexVariable : public ModelOb /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: Construction. ModelObject constructionObject() const; //@} /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: Construction. bool setConstructionObject(const ModelObject& construction); //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp index f6b5184a12e..ef4dade9cf1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp @@ -63,14 +63,12 @@ namespace detail { /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: Construction. ModelObject constructionObject() const; //@} /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: Construction. bool setConstructionObject(const ModelObject& construction); //@} diff --git a/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp new file mode 100644 index 00000000000..1c51bc67619 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp @@ -0,0 +1,94 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Model.hpp" +#include "../Model_Impl.hpp" +#include "../Building.hpp" +#include "../Building_Impl.hpp" +#include "../ThermalZone.hpp" +#include "../Component.hpp" +#include "../CFactorUndergroundWallConstruction.hpp" +#include "../CFactorUndergroundWallConstruction_Impl.hpp" +#include "../Construction.hpp" +#include "../Construction_Impl.hpp" +#include "../DefaultConstructionSet.hpp" +#include "../DefaultConstructionSet_Impl.hpp" +#include "../DefaultSurfaceConstructions.hpp" +#include "../DefaultSurfaceConstructions_Impl.hpp" +#include "../DefaultSubSurfaceConstructions.hpp" +#include "../DefaultSubSurfaceConstructions_Impl.hpp" +#include "../EnergyManagementSystemConstructionIndexVariable.hpp" +#include "../ConstructionWithInternalSource.hpp" +#include "../ConstructionWithInternalSource_Impl.hpp" +#include "../FFactorGroundFloorConstruction.hpp" +#include "../FFactorGroundFloorConstruction_Impl.hpp" +#include "../WindowDataFile.hpp" +#include "../WindowDataFile_Impl.hpp" +#include "../StandardsInformationConstruction.hpp" +#include "../StandardsInformationConstruction_Impl.hpp" + +#include "../Material.hpp" +#include "../Material_Impl.hpp" +#include "../AirGap.hpp" +#include "../AirWallMaterial.hpp" +#include "../StandardOpaqueMaterial.hpp" +#include "../StandardOpaqueMaterial_Impl.hpp" +#include "../StandardGlazing.hpp" +#include "../Space.hpp" +#include "../Space_Impl.hpp" +#include "../Surface.hpp" +#include "../Surface_Impl.hpp" +#include "../SubSurface.hpp" +#include "../SubSurface_Impl.hpp" +#include "../LifeCycleCost.hpp" + +#include "../../utilities/geometry/Point3d.hpp" +#include "../../utilities/idf/IdfFile.hpp" +#include +#include +#include +#include + +using namespace openstudio; +using namespace openstudio::model; + +TEST_F(ModelFixture, EMS_ConstructionIndexVariable) +{ + Model model; + + // Create some materials + StandardOpaqueMaterial exterior(model); + AirGap air(model); + StandardOpaqueMaterial interior(model); + + OpaqueMaterialVector layers; + layers.push_back(exterior); + layers.push_back(air); + layers.push_back(interior); + + Construction construction(layers); + + EnergyManagementSystemConstructionIndexVariable emsCIV(model); + emsCIV.setConstructionObject(construction); + EXPECT_EQ(construction.handle(), emsCIV.constructionObject().handle()); + model.save(toPath("./EMS_constructiontest.osm"), true); +} diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index a97e8896e0b..e739f0bc559 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -426,8 +426,8 @@ namespace detail { // get all EMS idd object types in both E+ and OS IDD case openstudio::IddObjectType::EnergyManagementSystem_Actuator:; // deliberate fall through case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through - //case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped - //case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped + case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through //case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped //case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through From d870b343701f3d56738e015973489e1e9b4a6585 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 19 Sep 2016 10:58:31 -0600 Subject: [PATCH 114/159] add EMS CurveOrTableIndexVariable to model --- openstudiocore/src/model/CMakeLists.txt | 1 + ...agementSystemCurveOrTableIndexVariable.cpp | 8 +--- ...agementSystemCurveOrTableIndexVariable.hpp | 2 - ...ntSystemCurveOrTableIndexVariable_Impl.hpp | 6 --- ...tSystemCurveOrTableIndexVariable_GTest.cpp | 47 +++++++++++++++++++ .../src/utilities/idf/IdfObject.cpp | 4 +- 6 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index bba13991ce4..4cc3f058c9d 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1641,6 +1641,7 @@ set(${target_name}_test_src test/ElectricLoadCenterStorageSimple_GTest.cpp test/EnergyManagementSystemActuator_GTest.cpp test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp + test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp test/EnergyManagementSystemGlobalVariable_GTest.cpp test/EnergyManagementSystemInternalVariable_GTest.cpp test/EnergyManagementSystemOutputVariable_GTest.cpp diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp index 34f15678370..ae060d17515 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -71,7 +71,7 @@ namespace detail { ModelObject EnergyManagementSystemCurveOrTableIndexVariable_Impl::curveorTableObject() const { boost::optional value = optionalCurveorTableObject(); if (!value) { - LOG_AND_THROW(briefDescription() << " does not have an Curveor Table Object attached."); + LOG(Info, " does not have an Curveor Table Object attached."); } return value.get(); } @@ -91,12 +91,6 @@ EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTa : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName - bool ok = true; - // ok = setCurveorTableObject(); - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp index 743615a4f7c..c023b84abbd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp @@ -52,14 +52,12 @@ class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable : public ModelOb /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: AllCurves. ModelObject curveorTableObject() const; //@} /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: AllCurves. bool setCurveorTableObject(const ModelObject& allCurves); //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp index 60115e17ba9..c76ca5a15a1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp @@ -63,14 +63,12 @@ namespace detail { /** @name Getters */ //@{ - // TODO: Check return type. From object lists, some candidates are: AllCurves. ModelObject curveorTableObject() const; //@} /** @name Setters */ //@{ - // TODO: Check argument type. From object lists, some candidates are: AllCurves. bool setCurveorTableObject(const ModelObject& allCurves); //@} @@ -82,10 +80,6 @@ namespace detail { private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemCurveOrTableIndexVariable"); - // TODO: Check the return types of these methods. - // Optional getters for use by methods like children() so can remove() if the constructor fails. - // There are other ways for the public versions of these getters to fail--perhaps all required - // objects should be returned as boost::optionals boost::optional optionalCurveorTableObject() const; }; diff --git a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp new file mode 100644 index 00000000000..9a60bb5d18f --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp @@ -0,0 +1,47 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../Model.hpp" +#include "../Model_Impl.hpp" +#include "../Curve.hpp" +#include "../CurveQuadratic.hpp" +#include "../CurveBiquadratic.hpp" +#include "../EnergyManagementSystemCurveOrTableIndexVariable.hpp" + +#include "../../utilities/idf/IdfFile.hpp" +#include + +using namespace openstudio; +using namespace openstudio::model; + +TEST_F(ModelFixture, EMS_CurveOrTableIndexVariable) +{ + Model model; + + // Create a curve + CurveBiquadratic c1(model); + + EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model); + emsCurve.setCurveorTableObject(c1); + EXPECT_EQ(c1.handle(), emsCurve.curveorTableObject().handle()); + model.save(toPath("./EMS_curvetest.osm"), true); +} diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index e739f0bc559..eb6cffffa5b 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -428,8 +428,8 @@ namespace detail { case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through - //case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped - //case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped + case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable:; // deliberate fall through case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable:; // deliberate fall through From f091781495f2e4d774a8bde8ff35f4e2de6aafa5 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 19 Sep 2016 14:20:35 -0600 Subject: [PATCH 115/159] add EMS meteredoutputvariable to model --- openstudiocore/src/model/CMakeLists.txt | 1 + ...yManagementSystemMeteredOutputVariable.cpp | 10 +-- ...ementSystemMeteredOutputVariable_GTest.cpp | 80 +++++++++++++++++++ ...ementSystemProgramCallingManager_GTest.cpp | 2 + 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 4cc3f058c9d..d0d1af9e2ed 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -1644,6 +1644,7 @@ set(${target_name}_test_src test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp test/EnergyManagementSystemGlobalVariable_GTest.cpp test/EnergyManagementSystemInternalVariable_GTest.cpp + test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp test/EnergyManagementSystemOutputVariable_GTest.cpp test/EnergyManagementSystemProgram_GTest.cpp test/EnergyManagementSystemProgramCallingManager_GTest.cpp diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index b525b859db3..e61500651ae 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -169,16 +169,14 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput { OS_ASSERT(getImpl()); - // TODO: Appropriately handle the following required object-list fields. - // setEMSVariableName(); bool ok = true; - // ok = setUpdateFrequency(); + ok = setUpdateFrequency("SystemTimestep"); OS_ASSERT(ok); - // ok = setResourceType(); + ok = setResourceType("Electricity"); OS_ASSERT(ok); - // ok = setGroupType(); + ok = setGroupType("Building"); OS_ASSERT(ok); - // ok = setEndUseCategory(); + ok = setEndUseCategory("Fans"); OS_ASSERT(ok); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp new file mode 100644 index 00000000000..81d1f80b560 --- /dev/null +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -0,0 +1,80 @@ +/********************************************************************** +* Copyright (c) 2008-2016, Alliance for Sustainable Energy. +* All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +**********************************************************************/ + +#include + +#include "ModelFixture.hpp" +#include "../EnergyManagementSystemMeteredOutputVariable.hpp" +#include "../EnergyManagementSystemSensor.hpp" +#include "../EnergyManagementSystemProgram.hpp" +#include "../Model_Impl.hpp" + +#include "../../utilities/idd/IddEnums.hpp" +#include "../../utilities/idf/ValidityReport.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/data/TimeSeries.hpp" +#include "../../utilities/core/Compare.hpp" +#include "../../utilities/core/Optional.hpp" + +using namespace openstudio; +using namespace openstudio::model; +using std::string; + +TEST_F(ModelFixture, EMSMeteredOutputVariable) +{ + Model model; + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); + + // add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add program + EnergyManagementSystemProgram program_1(model); + program_1.setName("program one"); + + // add metered output variable + EnergyManagementSystemMeteredOutputVariable meteredoutvar(model); + + meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); + EXPECT_EQ(meteredoutvar.eMSVariableName(), OATdbSensor.name().get()); + meteredoutvar.setUpdateFrequency("ZoneTimestep"); + EXPECT_EQ("ZoneTimestep",meteredoutvar.updateFrequency()); + meteredoutvar.setEMSProgramorSubroutineName(program_1.name().get()); + EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); + meteredoutvar.resetEMSProgramorSubroutineName(); + EXPECT_EQ("", meteredoutvar.eMSProgramorSubroutineName().get()); + meteredoutvar.setEMSProgramorSubroutineName(program_1.name().get()); + EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); + meteredoutvar.setResourceType("NaturalGas"); + EXPECT_EQ("NaturalGas", meteredoutvar.resourceType()); + meteredoutvar.setGroupType("HVAC"); + EXPECT_EQ("HVAC", meteredoutvar.groupType()); + meteredoutvar.setEndUseCategory("Heating"); + EXPECT_EQ("Heating", meteredoutvar.endUseCategory()); + meteredoutvar.setEndUseSubcategory("Madeup"); + EXPECT_EQ("Madeup", meteredoutvar.endUseSubcategory().get()); + + model.save(toPath("./EMS_meteredoutvar.osm"), true); +} + diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp index afc23e90515..8a3f0f35f9a 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp @@ -235,5 +235,7 @@ TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) program = fan_pcm.getProgram(2); EXPECT_EQ(true, program.is_initialized()); EXPECT_EQ(fan_program_3.nameString(), program.get().nameString()); + + model.save(toPath("./EMS_pcm.osm"), true); } From 8cfc43ed51da94fac8a535820acc8fa8a39e52c2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 19 Sep 2016 17:42:14 -0600 Subject: [PATCH 116/159] update EMS meteredoutputvariable program/subroutine to be object-list --- openstudiocore/resources/model/OpenStudio.idd | 2 +- ...yManagementSystemMeteredOutputVariable.cpp | 23 +++++++++++++++---- ...yManagementSystemMeteredOutputVariable.hpp | 6 ++++- ...gementSystemMeteredOutputVariable_Impl.hpp | 6 ++++- ...ementSystemMeteredOutputVariable_GTest.cpp | 11 ++++++--- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index ef6696fc40a..91ee2dd8869 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26589,7 +26589,7 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \key ZoneTimestep \key SystemTimestep A5 , \field EMS Program or Subroutine Name - \type alpha + \type object-list \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables A6 , \field Resource Type diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index e61500651ae..43bfc708fff 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -19,6 +19,10 @@ #include "EnergyManagementSystemMeteredOutputVariable.hpp" #include "EnergyManagementSystemMeteredOutputVariable_Impl.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" +#include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemSubroutine_Impl.hpp" #include #include @@ -117,9 +121,16 @@ namespace detail { return result; } - void EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { - bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, eMSProgramorSubroutineName); + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, program.handle()); OS_ASSERT(result); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); + OS_ASSERT(result); + return result; } void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { @@ -244,8 +255,12 @@ bool EnergyManagementSystemMeteredOutputVariable::setUpdateFrequency(const std:: return getImpl()->setUpdateFrequency(updateFrequency); } -void EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { - getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); +bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + return getImpl()->setEMSProgramorSubroutineName(program); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + return getImpl()->setEMSProgramorSubroutineName(subroutine); } void EnergyManagementSystemMeteredOutputVariable::resetEMSProgramorSubroutineName() { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index f947b54113a..e0fbaa19cb7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -22,6 +22,8 @@ #include #include "ModelObject.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemSubroutine.hpp" namespace openstudio { namespace model { @@ -81,7 +83,9 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject bool setUpdateFrequency(const std::string& updateFrequency); - void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + + bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); void resetEMSProgramorSubroutineName(); diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp index 63b3ea72f4a..3747f55e734 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp @@ -22,6 +22,8 @@ #include #include "ModelObject_Impl.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" +#include "EnergyManagementSystemSubroutine_Impl.hpp" namespace openstudio { namespace model { @@ -84,7 +86,9 @@ namespace detail { bool setUpdateFrequency(const std::string& updateFrequency); - void setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + + bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); void resetEMSProgramorSubroutineName(); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp index 81d1f80b560..4530b6b8902 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -23,6 +23,7 @@ #include "../EnergyManagementSystemMeteredOutputVariable.hpp" #include "../EnergyManagementSystemSensor.hpp" #include "../EnergyManagementSystemProgram.hpp" +#include "../EnergyManagementSystemSubroutine.hpp" #include "../Model_Impl.hpp" #include "../../utilities/idd/IddEnums.hpp" @@ -53,6 +54,10 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) EnergyManagementSystemProgram program_1(model); program_1.setName("program one"); + //add program + EnergyManagementSystemSubroutine subroutine_1(model); + subroutine_1.setName("subroutine one"); + // add metered output variable EnergyManagementSystemMeteredOutputVariable meteredoutvar(model); @@ -60,12 +65,12 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) EXPECT_EQ(meteredoutvar.eMSVariableName(), OATdbSensor.name().get()); meteredoutvar.setUpdateFrequency("ZoneTimestep"); EXPECT_EQ("ZoneTimestep",meteredoutvar.updateFrequency()); - meteredoutvar.setEMSProgramorSubroutineName(program_1.name().get()); + meteredoutvar.setEMSProgramorSubroutineName(program_1); EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); meteredoutvar.resetEMSProgramorSubroutineName(); EXPECT_EQ("", meteredoutvar.eMSProgramorSubroutineName().get()); - meteredoutvar.setEMSProgramorSubroutineName(program_1.name().get()); - EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); + meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); + EXPECT_EQ(subroutine_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); meteredoutvar.setResourceType("NaturalGas"); EXPECT_EQ("NaturalGas", meteredoutvar.resourceType()); meteredoutvar.setGroupType("HVAC"); From 92bcfccfab5365bd1e42990896fb81ba0ef118de Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 20 Sep 2016 11:14:41 -0600 Subject: [PATCH 117/159] add the rest of the EMS objects to the ForwardTranslator --- openstudiocore/src/energyplus/CMakeLists.txt | 3 + .../src/energyplus/ForwardTranslator.cpp | 21 +++ .../src/energyplus/ForwardTranslator.hpp | 9 + ...agementSystemConstructionIndexVariable.cpp | 64 +++++++ ...agementSystemCurveOrTableIndexVariable.cpp | 64 +++++++ ...yManagementSystemMeteredOutputVariable.cpp | 85 +++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 163 ++++++++++++++++++ 7 files changed, 409 insertions(+) create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemConstructionIndexVariable.cpp create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp create mode 100644 openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index f13eaa1abfa..9ee1115ae39 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -120,8 +120,11 @@ set(${target_name}_src ForwardTranslator/ForwardTranslateElectricLoadCenterInverterSimple.cpp ForwardTranslator/ForwardTranslateElectricLoadCenterStorageSimple.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemConstructionIndexVariable.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemInternalVariable.cpp + ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp diff --git a/openstudiocore/src/energyplus/ForwardTranslator.cpp b/openstudiocore/src/energyplus/ForwardTranslator.cpp index 00df36e670b..f4d46b0af78 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.cpp @@ -1329,6 +1329,18 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemActuator(actuator); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable: + { + model::EnergyManagementSystemConstructionIndexVariable civ = modelObject.cast(); + retVal = translateEnergyManagementSystemConstructionIndexVariable(civ); + break; + } + case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable: + { + model::EnergyManagementSystemCurveOrTableIndexVariable cotiv = modelObject.cast(); + retVal = translateEnergyManagementSystemCurveOrTableIndexVariable(cotiv); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable: { model::EnergyManagementSystemGlobalVariable globalVariable = modelObject.cast(); @@ -1341,6 +1353,12 @@ boost::optional ForwardTranslator::translateAndMapModelObject(ModelOb retVal = translateEnergyManagementSystemInternalVariable(internalVariable); break; } + case openstudio::IddObjectType::OS_EnergyManagementSystem_MeteredOutputVariable: + { + model::EnergyManagementSystemMeteredOutputVariable mov = modelObject.cast(); + retVal = translateEnergyManagementSystemMeteredOutputVariable(mov); + break; + } case openstudio::IddObjectType::OS_EnergyManagementSystem_OutputVariable: { model::EnergyManagementSystemOutputVariable outputVariable = modelObject.cast(); @@ -2994,6 +3012,9 @@ std::vector ForwardTranslator::iddObjectsToTranslateInitializer() result.push_back(IddObjectType::OS_EnergyManagementSystem_InternalVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_Sensor); result.push_back(IddObjectType::OS_EnergyManagementSystem_Actuator); + result.push_back(IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable); + result.push_back(IddObjectType::OS_EnergyManagementSystem_MeteredOutputVariable); result.push_back(IddObjectType::OS_EnergyManagementSystem_Program); result.push_back(IddObjectType::OS_EnergyManagementSystem_Subroutine); result.push_back(IddObjectType::OS_EnergyManagementSystem_ProgramCallingManager); diff --git a/openstudiocore/src/energyplus/ForwardTranslator.hpp b/openstudiocore/src/energyplus/ForwardTranslator.hpp index 55be9603212..8628ecadfda 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator.hpp +++ b/openstudiocore/src/energyplus/ForwardTranslator.hpp @@ -144,8 +144,11 @@ class ElectricLoadCenterInverterLookUpTable; class ElectricLoadCenterInverterSimple; class ElectricLoadCenterStorageSimple; class EnergyManagementSystemActuator; +class EnergyManagementSystemConstructionIndexVariable; +class EnergyManagementSystemCurveOrTableIndexVariable; class EnergyManagementSystemGlobalVariable; class EnergyManagementSystemInternalVariable; +class EnergyManagementSystemMeteredOutputVariable; class EnergyManagementSystemOutputVariable; class EnergyManagementSystemProgram; class EnergyManagementSystemProgramCallingManager; @@ -652,10 +655,16 @@ class ENERGYPLUS_API ForwardTranslator { boost::optional translateEnergyManagementSystemActuator(model::EnergyManagementSystemActuator & modelObject); + boost::optional translateEnergyManagementSystemConstructionIndexVariable(model::EnergyManagementSystemConstructionIndexVariable & modelObject); + + boost::optional translateEnergyManagementSystemCurveOrTableIndexVariable(model::EnergyManagementSystemCurveOrTableIndexVariable & modelObject); + boost::optional translateEnergyManagementSystemGlobalVariable(model::EnergyManagementSystemGlobalVariable & modelObject); boost::optional translateEnergyManagementSystemInternalVariable(model::EnergyManagementSystemInternalVariable & modelObject); + boost::optional translateEnergyManagementSystemMeteredOutputVariable(model::EnergyManagementSystemMeteredOutputVariable & modelObject); + boost::optional translateEnergyManagementSystemOutputVariable(model::EnergyManagementSystemOutputVariable & modelObject); boost::optional translateEnergyManagementSystemProgram(model::EnergyManagementSystemProgram & modelObject); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemConstructionIndexVariable.cpp new file mode 100644 index 00000000000..368ea32b63e --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -0,0 +1,64 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemConstructionIndexVariable.hpp" +#include "../../model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemConstructionIndexVariable(EnergyManagementSystemConstructionIndexVariable & modelObject) +{ + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + + idfObject.setString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName, modelObject.constructionObject().nameString()); + + return idfObject; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp new file mode 100644 index 00000000000..e4217055565 --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -0,0 +1,64 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemCurveOrTableIndexVariable(EnergyManagementSystemCurveOrTableIndexVariable & modelObject) +{ + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + + idfObject.setString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, modelObject.curveorTableObject().nameString()); + + return idfObject; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp new file mode 100644 index 00000000000..1cebe07f57c --- /dev/null +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -0,0 +1,85 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/OutputVariable.hpp" +#include "../../model/OutputVariable_Impl.hpp" +#include "../../model/OutputMeter.hpp" +#include "../../model/OutputMeter_Impl.hpp" +#include "../../model/Schedule.hpp" +#include "../../model/Schedule_Impl.hpp" +#include "../../model/EnergyManagementSystemMeteredOutputVariable.hpp" +#include "../../model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +using namespace std; + +namespace openstudio { + +namespace energyplus { + +boost::optional ForwardTranslator::translateEnergyManagementSystemMeteredOutputVariable(EnergyManagementSystemMeteredOutputVariable & modelObject) +{ + boost::optional s; + + IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_MeteredOutputVariable); + m_idfObjects.push_back(idfObject); + //Name + s = modelObject.name(); + if (s) { + idfObject.setName(*s); + } + + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, modelObject.eMSVariableName()); + + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, modelObject.updateFrequency()); + + s = modelObject.eMSProgramorSubroutineName(); + if (s.is_initialized()) { + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, s.get()); + } + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::ResourceType, modelObject.resourceType()); + + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::GroupType, modelObject.groupType()); + + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory, modelObject.endUseCategory()); + + s = modelObject.endUseSubcategory(); + if (s.is_initialized()) { + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, s.get()); + } + + s = modelObject.units(); + if (s.is_initialized()) { + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::Units, s.get()); + } + return idfObject; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 1dd27d53838..583b9282bd9 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -28,6 +28,28 @@ #include "../../model/Building.hpp" #include "../../model/Building_Impl.hpp" #include "../../model/ThermalZone.hpp" +#include "../../model/Component.hpp" +#include "../../model/CFactorUndergroundWallConstruction.hpp" +#include "../../model/CFactorUndergroundWallConstruction_Impl.hpp" +#include "../../model/Construction.hpp" +#include "../../model/Construction_Impl.hpp" +#include "../../model/Curve.hpp" +#include "../../model/CurveQuadratic.hpp" +#include "../../model/CurveBiquadratic.hpp" +#include "../../model/DefaultConstructionSet.hpp" +#include "../../model/DefaultConstructionSet_Impl.hpp" +#include "../../model/DefaultSurfaceConstructions.hpp" +#include "../../model/DefaultSurfaceConstructions_Impl.hpp" +#include "../../model/DefaultSubSurfaceConstructions.hpp" +#include "../../model/DefaultSubSurfaceConstructions_Impl.hpp" +#include "../../model/ConstructionWithInternalSource.hpp" +#include "../../model/ConstructionWithInternalSource_Impl.hpp" +#include "../../model/FFactorGroundFloorConstruction.hpp" +#include "../../model/FFactorGroundFloorConstruction_Impl.hpp" +#include "../../model/WindowDataFile.hpp" +#include "../../model/WindowDataFile_Impl.hpp" +#include "../../model/StandardsInformationConstruction.hpp" +#include "../../model/StandardsInformationConstruction_Impl.hpp" #include "../../model/FanConstantVolume.hpp" #include "../../model/FanConstantVolume_Impl.hpp" #include "../../model/OutputVariable.hpp" @@ -42,6 +64,12 @@ #include "../../model/EnergyManagementSystemSensor_Impl.hpp" #include "../../model/EnergyManagementSystemActuator.hpp" #include "../../model/EnergyManagementSystemActuator_Impl.hpp" +#include "../../model/EnergyManagementSystemConstructionIndexVariable.hpp" +#include "../../model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemMeteredOutputVariable.hpp" +#include "../../model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp" #include "../../model/EnergyManagementSystemProgram.hpp" #include "../../model/EnergyManagementSystemProgram_Impl.hpp" #include "../../model/EnergyManagementSystemSubroutine.hpp" @@ -57,9 +85,26 @@ #include "../../model/EnergyManagementSystemInternalVariable.hpp" #include "../../model/EnergyManagementSystemInternalVariable_Impl.hpp" +#include "../../model/Material.hpp" +#include "../../model/Material_Impl.hpp" +#include "../../model/AirGap.hpp" +#include "../../model/AirWallMaterial.hpp" +#include "../../model/StandardOpaqueMaterial.hpp" +#include "../../model/StandardOpaqueMaterial_Impl.hpp" +#include "../../model/StandardGlazing.hpp" +#include "../../model/Space.hpp" +#include "../../model/Space_Impl.hpp" +#include "../../model/Surface.hpp" +#include "../../model/Surface_Impl.hpp" +#include "../../model/SubSurface.hpp" +#include "../../model/SubSurface_Impl.hpp" +#include "../../model/LifeCycleCost.hpp" + #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" +#include "../../utilities/geometry/Point3d.hpp" + #include "../../utilities/core/Optional.hpp" #include "../../utilities/core/Checksum.hpp" #include "../../utilities/core/UUID.hpp" @@ -88,6 +133,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -703,4 +757,113 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorInternalVariable_EMS) { model.save(toPath("./EMS_InternalVariable.osm"), true); workspace.save(toPath("./EMS_InternalVariable.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorConstructionIndexVariable_EMS) { + Model model; + + // Create some materials + StandardOpaqueMaterial exterior(model); + AirGap air(model); + StandardOpaqueMaterial interior(model); + + OpaqueMaterialVector layers; + layers.push_back(exterior); + layers.push_back(air); + layers.push_back(interior); + + Construction construction(layers); + + EnergyManagementSystemConstructionIndexVariable emsCIV(model); + emsCIV.setConstructionObject(construction); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ConstructionIndexVariable).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_ConstructionIndexVariable)[0]; + ASSERT_TRUE(object.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName, false)); + EXPECT_EQ(construction.nameString(), object.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName, false).get()); + + model.save(toPath("./EMS_constructiontest.osm"), true); + workspace.save(toPath("./EMS_constructiontest.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorCurveOrTableIndexVariable_EMS) { + Model model; + + // Create a curve + CurveBiquadratic c1(model); + + EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model); + emsCurve.setCurveorTableObject(c1); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable)[0]; + ASSERT_TRUE(object.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, false)); + EXPECT_EQ(c1.nameString(), object.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, false).get()); + + model.save(toPath("./EMS_curvetest.osm"), true); + workspace.save(toPath("./EMS_curvetest.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { + Model model; + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + EXPECT_EQ("*", siteOutdoorAirDrybulbTemperature.keyValue()); + EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); + + // add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add program + EnergyManagementSystemProgram program_1(model); + program_1.setName("program one"); + + //add program + EnergyManagementSystemSubroutine subroutine_1(model); + subroutine_1.setName("subroutine one"); + + // add metered output variable + EnergyManagementSystemMeteredOutputVariable meteredoutvar(model); + + meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); + meteredoutvar.setUpdateFrequency("ZoneTimestep"); + meteredoutvar.setEMSProgramorSubroutineName(program_1); + meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); + meteredoutvar.setResourceType("NaturalGas"); + meteredoutvar.setGroupType("HVAC"); + meteredoutvar.setEndUseCategory("Heating"); + meteredoutvar.setEndUseSubcategory("Madeup"); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_MeteredOutputVariable).size()); + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_MeteredOutputVariable)[0]; + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, false)); + EXPECT_EQ(OATdbSensor.name().get(), object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, false)); + EXPECT_EQ("ZoneTimestep", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, false)); + EXPECT_EQ(subroutine_1.name().get(), object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::ResourceType, false)); + EXPECT_EQ("NaturalGas", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::ResourceType, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::GroupType, false)); + EXPECT_EQ("HVAC", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::GroupType, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory, false)); + EXPECT_EQ("Heating", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, false)); + EXPECT_EQ("Madeup", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, false).get()); + //ASSERT_TRUE(object.getString(EnergyManagementSystem_MeteredOutputVariableFields::Units, false)); + //EXPECT_EQ("", object.getString(EnergyManagementSystem_MeteredOutputVariableFields::Units, false).get()); + + model.save(toPath("./EMS_meteredoutvar.osm"), true); + workspace.save(toPath("./EMS_meteredoutvar.idf"), true); } \ No newline at end of file From 69affeb17a69b05df08437f1c3ced982c7eac0f7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 20 Sep 2016 15:30:08 -0600 Subject: [PATCH 118/159] ReverseTranslate EMS Sensor --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ReverseTranslator.cpp | 5 + .../src/energyplus/ReverseTranslator.hpp | 2 + ...eTranslateEnergyManagementSystemSensor.cpp | 91 +++++++++++++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 12 +++ 5 files changed, 111 insertions(+) create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 9ee1115ae39..6f70cfa28bc 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -372,6 +372,7 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateDesignSpecificationOutdoorAir.cpp ReverseTranslator/ReverseTranslateElectricEquipment.cpp ReverseTranslator/ReverseTranslateElectricLoadCenterStorageSimple.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp ReverseTranslator/ReverseTranslateEvaporativeCoolerDirectResearchSpecial.cpp ReverseTranslator/ReverseTranslateEvaporativeFluidCoolerSingleSpeed.cpp ReverseTranslator/ReverseTranslateExteriorLights.cpp diff --git a/openstudiocore/src/energyplus/ReverseTranslator.cpp b/openstudiocore/src/energyplus/ReverseTranslator.cpp index 33ba17a4c93..ec089455683 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.cpp @@ -479,6 +479,11 @@ boost::optional ReverseTranslator::translateAndMapWorkspaceObject(c modelObject = translateElectricLoadCenterStorageSimple(workspaceObject); break; } + case openstudio::IddObjectType::EnergyManagementSystem_Sensor: + { + modelObject = translateEnergyManagementSystemSensor(workspaceObject); + break; + } case openstudio::IddObjectType::EvaporativeCooler_Direct_ResearchSpecial : { //modelObject = translateEvaporativeCoolerDirectResearchSpecial(workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator.hpp b/openstudiocore/src/energyplus/ReverseTranslator.hpp index 8a412aab7c6..0c8d9995d82 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.hpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.hpp @@ -138,6 +138,8 @@ class ENERGYPLUS_API ReverseTranslator { boost::optional translateElectricEquipment(const WorkspaceObject & workspaceObject); boost::optional translateElectricLoadCenterStorageSimple(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject); boost::optional translateEvaporativeCoolerDirectResearchSpecial(const WorkspaceObject & workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp new file mode 100644 index 00000000000..034b5232c78 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp @@ -0,0 +1,91 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemSensor.hpp" +#include "../../model/EnergyManagementSystemSensor_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Sensor) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Sensor"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Name); + if(!s){ + return boost::none; + } + + openstudio::model::EnergyManagementSystemSensor emsSensor(m_model); + + if (s) { + emsSensor.setName(*s); + } + + Workspace workspace = workspaceObject.workspace(); + + s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName); + if (s) { + for (const WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::Output_Variable)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + boost::optional outvar = modelObject->optionalCast(); + if (outvar) { + if (outvar.get().variableName() == s) { + emsSensor.setOutputVariable(outvar.get()); + break; + } + } + } + } + for (const WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::Output_Meter)) { + boost::optional outvar = wsObject.optionalCast(); + if (outvar) { + if (outvar.get().name() == s) { + emsSensor.setOutputMeter(wsObject.cast()); + break; + } + } + } + } + + s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName); + if(s){ + emsSensor.setKeyName(*s); + } + + return emsSensor; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 583b9282bd9..4e355c596cb 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -196,6 +196,18 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { workspace.save(toPath("./EMS_sensor1.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorSensor1_EMS) { + + openstudio::path idfPath = toPath("./EMS_sensor1.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_sensor1a.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { Model model; From 6ac19ea356df9fa833c65a19322ea952816ecb6f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 21 Sep 2016 09:24:06 -0600 Subject: [PATCH 119/159] ReverseTranslate EMS Actuator --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + .../src/energyplus/ReverseTranslator.cpp | 5 + .../src/energyplus/ReverseTranslator.hpp | 4 +- ...ranslateEnergyManagementSystemActuator.cpp | 99 +++++++++++++++++++ .../src/energyplus/Test/EMS_GTest.cpp | 12 +++ .../model/EnergyManagementSystemActuator.cpp | 5 + .../model/EnergyManagementSystemActuator.hpp | 2 + 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 6f70cfa28bc..5b3b8b261bc 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -372,6 +372,7 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateDesignSpecificationOutdoorAir.cpp ReverseTranslator/ReverseTranslateElectricEquipment.cpp ReverseTranslator/ReverseTranslateElectricLoadCenterStorageSimple.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp ReverseTranslator/ReverseTranslateEvaporativeCoolerDirectResearchSpecial.cpp ReverseTranslator/ReverseTranslateEvaporativeFluidCoolerSingleSpeed.cpp diff --git a/openstudiocore/src/energyplus/ReverseTranslator.cpp b/openstudiocore/src/energyplus/ReverseTranslator.cpp index ec089455683..826003fc927 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.cpp @@ -479,6 +479,11 @@ boost::optional ReverseTranslator::translateAndMapWorkspaceObject(c modelObject = translateElectricLoadCenterStorageSimple(workspaceObject); break; } + case openstudio::IddObjectType::EnergyManagementSystem_Actuator: + { + modelObject = translateEnergyManagementSystemActuator(workspaceObject); + break; + } case openstudio::IddObjectType::EnergyManagementSystem_Sensor: { modelObject = translateEnergyManagementSystemSensor(workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator.hpp b/openstudiocore/src/energyplus/ReverseTranslator.hpp index 0c8d9995d82..688d3b36121 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.hpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.hpp @@ -139,8 +139,10 @@ class ENERGYPLUS_API ReverseTranslator { boost::optional translateElectricLoadCenterStorageSimple(const WorkspaceObject & workspaceObject); - boost::optional translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject); + boost::optional translateEnergyManagementSystemActuator(const WorkspaceObject & workspaceObject); + boost::optional translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject); + boost::optional translateEvaporativeCoolerDirectResearchSpecial(const WorkspaceObject & workspaceObject); boost::optional translateEvaporativeFluidCoolerSingleSpeed(const WorkspaceObject & workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp new file mode 100644 index 00000000000..0970541be47 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp @@ -0,0 +1,99 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemActuator.hpp" +#include "../../model/EnergyManagementSystemActuator_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Actuator) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Actuator"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); + if(!s){ + return boost::none; + } + + s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); + if (!s) { + return boost::none; + } + + Workspace workspace = workspaceObject.workspace(); + + if (s) { + for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + openstudio::model::EnergyManagementSystemActuator emsActuator(modelObject.get()); + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); + emsActuator.setName(*s1); + emsActuator.setActuatedComponent(modelObject.get()); + s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType); + if (s1) { + emsActuator.setActuatedComponentType(*s1); + } + + s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType); + if (s1) { + emsActuator.setActuatedComponentControlType(*s1); + } + return emsActuator; + } else { + LOG(Error, "ATTENTION: Actuated Object " + wsObject.nameString() + " does not reverse translate. ActuatedComponent is NOT set."); + openstudio::model::EnergyManagementSystemActuator emsActuator(m_model); + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); + emsActuator.setName(*s1); + s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); + //Set actuated component as a comment since it cannot be reverse translated. + emsActuator.setComment("Actuated Component Name = " + *s1); + s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType); + if (s1) { + emsActuator.setActuatedComponentType(*s1); + } + + s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType); + if (s1) { + emsActuator.setActuatedComponentControlType(*s1); + } + return emsActuator; + } + } + } + return boost::none; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 4e355c596cb..97e43e6b060 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -325,6 +325,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { workspace.save(toPath("./EMS_example.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorActuator1_EMS) { + + openstudio::path idfPath = toPath("./EMS_example.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_examplea.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { Model model; diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index cb7aa9d1e43..35d60009ece 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -109,6 +109,11 @@ EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject setActuatedComponent(modelObject); } +EnergyManagementSystemActuator::EnergyManagementSystemActuator(const Model& model) + : ModelObject(EnergyManagementSystemActuator::iddObjectType(), model) { + OS_ASSERT(getImpl()); +} + IddObjectType EnergyManagementSystemActuator::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Actuator); } diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index e59e0f73801..b58d959bdc6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -40,6 +40,8 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { explicit EnergyManagementSystemActuator(const ModelObject& modelObject); + explicit EnergyManagementSystemActuator(const Model& model); + virtual ~EnergyManagementSystemActuator() {} //@} From 82adc438f136be41ea82ec1489d0d3d236d31268 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 21 Sep 2016 17:21:11 -0600 Subject: [PATCH 120/159] Reverse Translate EMS --- openstudiocore/src/energyplus/CMakeLists.txt | 11 + .../src/energyplus/ReverseTranslator.cpp | 55 +++++ .../src/energyplus/ReverseTranslator.hpp | 22 ++ ...agementSystemConstructionIndexVariable.cpp | 72 +++++++ ...agementSystemCurveOrTableIndexVariable.cpp | 72 +++++++ ...teEnergyManagementSystemGlobalVariable.cpp | 65 ++++++ ...EnergyManagementSystemInternalVariable.cpp | 65 ++++++ ...yManagementSystemMeteredOutputVariable.cpp | 129 ++++++++++++ ...teEnergyManagementSystemOutputVariable.cpp | 106 ++++++++++ ...TranslateEnergyManagementSystemProgram.cpp | 74 +++++++ ...yManagementSystemProgramCallingManager.cpp | 83 ++++++++ ...nslateEnergyManagementSystemSubroutine.cpp | 74 +++++++ ...ateEnergyManagementSystemTrendVariable.cpp | 88 ++++++++ ...eTranslateOutputEnergyManagementSystem.cpp | 60 ++++++ .../src/energyplus/Test/EMS_GTest.cpp | 195 +++++++++++++++++- .../EnergyManagementSystemOutputVariable.cpp | 23 ++- .../EnergyManagementSystemOutputVariable.hpp | 6 +- ...rgyManagementSystemOutputVariable_Impl.hpp | 4 +- ...gyManagementSystemOutputVariable_GTest.cpp | 7 +- 19 files changed, 1199 insertions(+), 12 deletions(-) create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp create mode 100644 openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateOutputEnergyManagementSystem.cpp diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 5b3b8b261bc..4ad56507dde 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -373,7 +373,17 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateElectricEquipment.cpp ReverseTranslator/ReverseTranslateElectricLoadCenterStorageSimple.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp ReverseTranslator/ReverseTranslateEvaporativeCoolerDirectResearchSpecial.cpp ReverseTranslator/ReverseTranslateEvaporativeFluidCoolerSingleSpeed.cpp ReverseTranslator/ReverseTranslateExteriorLights.cpp @@ -392,6 +402,7 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateMeterCustom.cpp ReverseTranslator/ReverseTranslateMeterCustomDecrement.cpp ReverseTranslator/ReverseTranslateOtherEquipment.cpp + ReverseTranslator/ReverseTranslateOutputEnergyManagementSystem.cpp ReverseTranslator/ReverseTranslateOutputIlluminanceMap.cpp ReverseTranslator/ReverseTranslateOutputMeter.cpp ReverseTranslator/ReverseTranslateOutputMeterCumulative.cpp diff --git a/openstudiocore/src/energyplus/ReverseTranslator.cpp b/openstudiocore/src/energyplus/ReverseTranslator.cpp index 826003fc927..421e801f62f 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.cpp @@ -484,11 +484,61 @@ boost::optional ReverseTranslator::translateAndMapWorkspaceObject(c modelObject = translateEnergyManagementSystemActuator(workspaceObject); break; } + case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable: + { + modelObject = translateEnergyManagementSystemConstructionIndexVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable: + { + modelObject = translateEnergyManagementSystemCurveOrTableIndexVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable: + { + modelObject = translateEnergyManagementSystemGlobalVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable: + { + modelObject = translateEnergyManagementSystemInternalVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_MeteredOutputVariable: + { + modelObject = translateEnergyManagementSystemMeteredOutputVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_OutputVariable: + { + modelObject = translateEnergyManagementSystemOutputVariable(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_Program: + { + modelObject = translateEnergyManagementSystemProgram(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_ProgramCallingManager: + { + modelObject = translateEnergyManagementSystemProgramCallingManager(workspaceObject); + break; + } case openstudio::IddObjectType::EnergyManagementSystem_Sensor: { modelObject = translateEnergyManagementSystemSensor(workspaceObject); break; } + case openstudio::IddObjectType::EnergyManagementSystem_Subroutine: + { + modelObject = translateEnergyManagementSystemSubroutine(workspaceObject); + break; + } + case openstudio::IddObjectType::EnergyManagementSystem_TrendVariable: + { + modelObject = translateEnergyManagementSystemTrendVariable(workspaceObject); + break; + } case openstudio::IddObjectType::EvaporativeCooler_Direct_ResearchSpecial : { //modelObject = translateEvaporativeCoolerDirectResearchSpecial(workspaceObject); @@ -596,6 +646,11 @@ boost::optional ReverseTranslator::translateAndMapWorkspaceObject(c { break; // no-op } + case openstudio::IddObjectType::Output_EnergyManagementSystem: + { + modelObject = translateOutputEnergyManagementSystem(workspaceObject); + break; + } case openstudio::IddObjectType::Output_IlluminanceMap : { modelObject = translateOutputIlluminanceMap(workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator.hpp b/openstudiocore/src/energyplus/ReverseTranslator.hpp index 688d3b36121..a965fd336bd 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator.hpp +++ b/openstudiocore/src/energyplus/ReverseTranslator.hpp @@ -140,9 +140,29 @@ class ENERGYPLUS_API ReverseTranslator { boost::optional translateElectricLoadCenterStorageSimple(const WorkspaceObject & workspaceObject); boost::optional translateEnergyManagementSystemActuator(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemConstructionIndexVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemCurveOrTableIndexVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemGlobalVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemInternalVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemMeteredOutputVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemOutputVariable(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemProgram(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemProgramCallingManager(const WorkspaceObject & workspaceObject); boost::optional translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject); + boost::optional translateEnergyManagementSystemSubroutine(const WorkspaceObject & workspaceObject); + + boost::optional translateEnergyManagementSystemTrendVariable(const WorkspaceObject & workspaceObject); + boost::optional translateEvaporativeCoolerDirectResearchSpecial(const WorkspaceObject & workspaceObject); boost::optional translateEvaporativeFluidCoolerSingleSpeed(const WorkspaceObject & workspaceObject); @@ -179,6 +199,8 @@ class ENERGYPLUS_API ReverseTranslator { boost::optional translateOtherEquipment(const WorkspaceObject& workspaceObject); + boost::optional translateOutputEnergyManagementSystem(const WorkspaceObject & workspaceObject); + boost::optional translateOutputIlluminanceMap( const WorkspaceObject& workspaceObject); boost::optional translateOutputMeter( const WorkspaceObject& workspaceObject); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp new file mode 100644 index 00000000000..5d136bf0ded --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -0,0 +1,72 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemConstructionIndexVariable.hpp" +#include "../../model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructionIndexVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ConstructionIndexVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_ConstructionIndexVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name); + if(!s){ + return boost::none; + } + + s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); + if (!s) { + return boost::none; + } + + Workspace workspace = workspaceObject.workspace(); + + if (s) { + for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model); + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name); + emsConstructionIndexVariable.setName(*s1); + emsConstructionIndexVariable.setConstructionObject(modelObject.get()); + return emsConstructionIndexVariable; + } + } + } + return boost::none; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp new file mode 100644 index 00000000000..83d3fa4caa5 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -0,0 +1,72 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "../../model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTableIndexVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_CurveOrTableIndexVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name); + if(!s){ + return boost::none; + } + + s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); + if (!s) { + return boost::none; + } + + Workspace workspace = workspaceObject.workspace(); + + if (s) { + for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + openstudio::model::EnergyManagementSystemCurveOrTableIndexVariable emsCurveOrTableIndexVariable(m_model); + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name); + emsCurveOrTableIndexVariable.setName(*s1); + emsCurveOrTableIndexVariable.setCurveorTableObject(modelObject.get()); + return emsCurveOrTableIndexVariable; + } + } + } + return boost::none; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp new file mode 100644 index 00000000000..a5d84771ae1 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp @@ -0,0 +1,65 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" + +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemGlobalVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_GlobalVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_GlobalVariable"); + return boost::none; + } + + if (workspaceObject.numExtensibleGroups() > 1) { + LOG(Warn, "EnergyManagementSystem GlobalVariable has more than 1 value."); + } + + OptionalModelObject result; + for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { + boost::optional value = eg.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName); + if (value) { + openstudio::model::EnergyManagementSystemGlobalVariable emsGlobalVariable(value.get(), m_model); + if (!result) { + result = emsGlobalVariable; + } + } + } + + return result; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp new file mode 100644 index 00000000000..3b8bd2916ef --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp @@ -0,0 +1,65 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemInternalVariable.hpp" +#include "../../model/EnergyManagementSystemInternalVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemInternalVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_InternalVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_InternalVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_InternalVariableFields::Name); + if(!s){ + return boost::none; + } + + openstudio::model::EnergyManagementSystemInternalVariable emsInternalVariable(m_model); + emsInternalVariable.setName(*s); + + s = workspaceObject.getString(EnergyManagementSystem_InternalVariableFields::InternalDataType); + if (s) { + emsInternalVariable.setInternalDataType(*s); + } + s = workspaceObject.getString(EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName); + if (s) { + emsInternalVariable.setInternalDataIndexKeyName(*s); + } + + return emsInternalVariable; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp new file mode 100644 index 00000000000..9bd08b5f9af --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -0,0 +1,129 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemMeteredOutputVariable.hpp" +#include "../../model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" +#include "../../model/EnergyManagementSystemSubroutine.hpp" +#include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOutputVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_MeteredOutputVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::Name); + if(!s){ + LOG(Error, "EnergyManagementSystem_MeteredOutputVariable Name not set"); + return boost::none; + } + openstudio::model::EnergyManagementSystemMeteredOutputVariable emsOutputVariable(m_model); + emsOutputVariable.setName(*s); + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); + return boost::none; + } else { + emsOutputVariable.setEMSVariableName(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": UpdateFrequency not set"); + return boost::none; + } else { + emsOutputVariable.setUpdateFrequency(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::ResourceType); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": ResourceType not set"); + return boost::none; + } else { + emsOutputVariable.setResourceType(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::GroupType); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": GroupType not set"); + return boost::none; + } else { + emsOutputVariable.setGroupType(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": EndUseCategory not set"); + return boost::none; + } else { + emsOutputVariable.setEndUseCategory(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory); + if (s) { + emsOutputVariable.setEndUseSubcategory(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::Units); + if (s) { + emsOutputVariable.setUnits(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName); + if (s) { + Workspace workspace = workspaceObject.workspace(); + for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Program) { + EnergyManagementSystemProgram program = modelObject.get().cast(); + emsOutputVariable.setEMSProgramorSubroutineName(program); + } else if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Subroutine) { + EnergyManagementSystemSubroutine subroutine = modelObject.get().cast(); + emsOutputVariable.setEMSProgramorSubroutineName(subroutine); + } + return emsOutputVariable; + } + } + + } + + return emsOutputVariable; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp new file mode 100644 index 00000000000..2b33ef092aa --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -0,0 +1,106 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemOutputVariable.hpp" +#include "../../model/EnergyManagementSystemOutputVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" +#include "../../model/EnergyManagementSystemSubroutine.hpp" +#include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_OutputVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Name); + if (!s) { + LOG(Error, "EnergyManagementSystem_OutputVariable Name not set"); + return boost::none; + } + openstudio::model::EnergyManagementSystemOutputVariable emsOutputVariable(m_model); + emsOutputVariable.setName(*s); + + s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::EMSVariableName); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); + return boost::none; + } else { + emsOutputVariable.setEMSVariableName(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::UpdateFrequency); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": UpdateFrequency not set"); + return boost::none; + } else { + emsOutputVariable.setUpdateFrequency(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": TypeofDatainVariable not set"); + return boost::none; + } else { + emsOutputVariable.setTypeofDatainVariable(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Units); + if (s) { + emsOutputVariable.setUnits(*s); + } + + s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName); + if (s) { + Workspace workspace = workspaceObject.workspace(); + for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + if (modelObject.get().iddObjectType() == IddObjectType::EnergyManagementSystem_Program) { + emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); + } else if (modelObject.get().iddObjectType() == IddObjectType::EnergyManagementSystem_Subroutine) { + emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); + } + return emsOutputVariable; + } + } + + } + + return emsOutputVariable; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp new file mode 100644 index 00000000000..1f2ff29ab39 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp @@ -0,0 +1,74 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgram(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Program"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ProgramFields::Name); + if(!s){ + return boost::none; + } + + openstudio::model::EnergyManagementSystemProgram emsProgram(m_model); + + if (s) { + emsProgram.setName(*s); + } + + //for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { + //emsProgram.pushExtensibleGroup(eg.fields()); + //} + unsigned n = workspaceObject.numExtensibleGroups(); + //OptionalWorkspaceObject line; + OptionalString line; + for (unsigned i = 0; i < n; ++i) { + line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); + if (line) { + emsProgram.addLine(line.get()); + } + } + return emsProgram; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp new file mode 100644 index 00000000000..1837e8a8c93 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp @@ -0,0 +1,83 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemProgramCallingManager.hpp" +#include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp" +#include "../../model/EnergyManagementSystemProgram.hpp" +#include "../../model/EnergyManagementSystemProgram_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCallingManager(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_ProgramCallingManager"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::Name); + if(!s){ + return boost::none; + } + + openstudio::model::EnergyManagementSystemProgramCallingManager emsProgramCallingManager(m_model); + emsProgramCallingManager.setName(*s); + + s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); + if (!s) { + return boost::none; + } else { + emsProgramCallingManager.setCallingPoint(*s); + } + + Workspace workspace = workspaceObject.workspace(); + + unsigned n = workspaceObject.numExtensibleGroups(); + OptionalWorkspaceObject owo; + OptionalModelObject omo; + for (unsigned i = 0; i < n; ++i) { + owo = workspaceObject.getExtensibleGroup(i).cast().getTarget(EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName); + if (owo) { + omo = translateAndMapWorkspaceObject(owo.get()); + if (omo) { + emsProgramCallingManager.addProgram(omo.get().cast()); + } + } + } + + return emsProgramCallingManager; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp new file mode 100644 index 00000000000..58eea059fcb --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp @@ -0,0 +1,74 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemSubroutine.hpp" +#include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" + +#include "../../utilities/idf/IdfExtensibleGroup.hpp" +#include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSubroutine(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_Subroutine"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_SubroutineFields::Name); + if (!s) { + return boost::none; + } + + openstudio::model::EnergyManagementSystemSubroutine emsProgram(m_model); + + if (s) { + emsProgram.setName(*s); + } + + //for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { + //emsProgram.pushExtensibleGroup(eg.fields()); + //} + unsigned n = workspaceObject.numExtensibleGroups(); + //OptionalWorkspaceObject line; + OptionalString line; + for (unsigned i = 0; i < n; ++i) { + line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); + if (line) { + emsProgram.addLine(line.get()); + } + } + return emsProgram; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp new file mode 100644 index 00000000000..03c2c123404 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp @@ -0,0 +1,88 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/EnergyManagementSystemTrendVariable.hpp" +#include "../../model/EnergyManagementSystemTrendVariable_Impl.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVariable(const WorkspaceObject & workspaceObject) +{ + if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_TrendVariable) { + LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_TrendVariable"); + return boost::none; + } + + OptionalString s = workspaceObject.getString(EnergyManagementSystem_TrendVariableFields::Name); + if(!s){ + return boost::none; + } + + openstudio::model::EnergyManagementSystemTrendVariable emsTrendVariable(m_model); + emsTrendVariable.setName(*s); + + boost::optional i = workspaceObject.getInt(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged); + if (!i) { + return boost::none; + } else { + emsTrendVariable.setNumberofTimestepstobeLogged(*i); + } + + s = workspaceObject.getString(EnergyManagementSystem_TrendVariableFields::EMSVariableName); + if (!s) { + return boost::none; + } else { + Workspace workspace = workspaceObject.workspace(); + for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + if (modelObject.get().cast().name() == s) { + emsTrendVariable.setEMSVariableName(*s); + return emsTrendVariable; + } + } + } + for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + emsTrendVariable.setEMSVariableName(*s); + return emsTrendVariable; + } + } + } + + return emsTrendVariable; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateOutputEnergyManagementSystem.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateOutputEnergyManagementSystem.cpp new file mode 100644 index 00000000000..865acc0b800 --- /dev/null +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateOutputEnergyManagementSystem.cpp @@ -0,0 +1,60 @@ +/********************************************************************** + * Copyright (c) 2008-2016, Alliance for Sustainable Energy. + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **********************************************************************/ + +#include "../ReverseTranslator.hpp" + +#include "../../model/OutputEnergyManagementSystem.hpp" +#include "../../model/OutputEnergyManagementSystem_Impl.hpp" + +#include +#include "../../utilities/idd/IddEnums.hpp" +#include + +using namespace openstudio::model; + +namespace openstudio { + +namespace energyplus { + +OptionalModelObject ReverseTranslator::translateOutputEnergyManagementSystem(const WorkspaceObject & workspaceObject) +{ + openstudio::model::OutputEnergyManagementSystem outputEMS = m_model.getUniqueModelObject(); + + OptionalString s = workspaceObject.getString(Output_EnergyManagementSystemFields::ActuatorAvailabilityDictionaryReporting); + if(s){ + outputEMS.setActuatorAvailabilityDictionaryReporting(*s); + } + + s = workspaceObject.getString(Output_EnergyManagementSystemFields::InternalVariableAvailabilityDictionaryReporting); + if (s) { + outputEMS.setInternalVariableAvailabilityDictionaryReporting(*s); + } + + s = workspaceObject.getString(Output_EnergyManagementSystemFields::EMSRuntimeLanguageDebugOutputLevel); + if (s) { + outputEMS.setEMSRuntimeLanguageDebugOutputLevel(*s); + } + + return outputEMS; +} + +} // energyplus + +} // openstudio + diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 97e43e6b060..aa2d523d1de 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -204,7 +204,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorSensor1_EMS) { Workspace inWorkspace(*idfFile); ReverseTranslator reverseTranslator; Model model = reverseTranslator.translateWorkspace(inWorkspace); - model.save(toPath("./EMS_sensor1a.osm"), true); + model.save(toPath("./EMS_sensor1T.osm"), true); } @@ -325,7 +325,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { workspace.save(toPath("./EMS_example.idf"), true); } -TEST_F(EnergyPlusFixture, ReverseTranslatorActuator1_EMS) { +TEST_F(EnergyPlusFixture, ReverseTranslatorActuator_EMS) { openstudio::path idfPath = toPath("./EMS_example.idf"); OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); @@ -333,7 +333,7 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorActuator1_EMS) { Workspace inWorkspace(*idfFile); ReverseTranslator reverseTranslator; Model model = reverseTranslator.translateWorkspace(inWorkspace); - model.save(toPath("./EMS_examplea.osm"), true); + model.save(toPath("./EMS_exampleT.osm"), true); } @@ -406,6 +406,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { workspace.save(toPath("./EMS_program.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorProgram_EMS) { + + openstudio::path idfPath = toPath("./EMS_program.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_programT.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { Model model; @@ -475,6 +487,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { workspace.save(toPath("./EMS_subroutine.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorSubroutine_EMS) { + + openstudio::path idfPath = toPath("./EMS_subroutine.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_subroutineT.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { Model model; @@ -634,6 +658,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { workspace.save(toPath("./EMS_PCM.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorProgramCallingManager_EMS) { + + openstudio::path idfPath = toPath("./EMS_PCM.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_PCMT.osm"), true); + +} + TEST_F(EnergyPlusFixture, noForwardTranslatorOutput_EMS) { Model model; @@ -662,6 +698,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutput_EMS) { model.save(toPath("./EMS_output.osm"), true); workspace.save(toPath("./EMS_output.idf"), true); +} + +TEST_F(EnergyPlusFixture, ReverseTranslatorOutput_EMS) { + + openstudio::path idfPath = toPath("./EMS_output.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_outputT.osm"), true); } @@ -689,6 +736,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGlobalVariable_EMS) { workspace.save(toPath("./EMS_GlobalVariable.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorGlobalVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_GlobalVariable.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_GlobalVariableT.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { Model model; @@ -730,6 +789,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { workspace.save(toPath("./EMS_OutputVariable.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorOutputVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_OutputVariable.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_OutputVariableT.osm"), true); + +} TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { Model model; @@ -760,6 +830,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { workspace.save(toPath("./EMS_TrendVariable.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorTrendVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_TrendVariable.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_TrendVariableT.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorInternalVariable_EMS) { Model model; @@ -783,6 +865,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorInternalVariable_EMS) { workspace.save(toPath("./EMS_InternalVariable.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorInternalVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_InternalVariable.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_InternalVariableT.osm"), true); + + +} TEST_F(EnergyPlusFixture, ForwardTranslatorConstructionIndexVariable_EMS) { Model model; @@ -813,6 +907,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorConstructionIndexVariable_EMS) { workspace.save(toPath("./EMS_constructiontest.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorConstructionIndexVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_constructiontest.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_constructiontestT.osm"), true); + + +} TEST_F(EnergyPlusFixture, ForwardTranslatorCurveOrTableIndexVariable_EMS) { Model model; @@ -834,6 +940,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorCurveOrTableIndexVariable_EMS) { workspace.save(toPath("./EMS_curvetest.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorCurveOrTableIndexVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_curvetest.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_curvetestT.osm"), true); + +} + TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { Model model; // add Site Outdoor Air Drybulb Temperature @@ -890,4 +1008,75 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { model.save(toPath("./EMS_meteredoutvar.osm"), true); workspace.save(toPath("./EMS_meteredoutvar.idf"), true); +} +TEST_F(EnergyPlusFixture, ReverseTranslatorMeteredOutputVariable_EMS) { + + openstudio::path idfPath = toPath("./EMS_meteredoutvar.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_meteredoutvarT.osm"), true); + +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { + Model model; + + // add global variable + EnergyManagementSystemGlobalVariable globvar("glob var", model); + + // add trend variable + EnergyManagementSystemTrendVariable var(model); + var.setName("TestName"); + EXPECT_EQ("TestName", var.name().get()); + var.setEMSVariableName("glob_var"); + EXPECT_EQ("glob_var", var.eMSVariableName()); + + var.setNumberofTimestepstobeLogged(2); + EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + + // Create some materials + StandardOpaqueMaterial exterior(model); + AirGap air(model); + StandardOpaqueMaterial interior(model); + + OpaqueMaterialVector layers; + layers.push_back(exterior); + layers.push_back(air); + layers.push_back(interior); + + Construction construction(layers); + + EnergyManagementSystemConstructionIndexVariable emsCIV(model); + emsCIV.setConstructionObject(construction); + + // add trend variable + EnergyManagementSystemTrendVariable var2(model); + var2.setName("TestName2"); + EXPECT_EQ("TestName2", var2.name().get()); + var2.setEMSVariableName(emsCIV.name().get()); + EXPECT_EQ(emsCIV.name().get(), var2.eMSVariableName()); + + var2.setNumberofTimestepstobeLogged(3); + EXPECT_EQ(3, var2.numberofTimestepstobeLogged()); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + + model.save(toPath("./EMS_TrendVariable2.osm"), true); + workspace.save(toPath("./EMS_TrendVariable2.idf"), true); +} + +TEST_F(EnergyPlusFixture, ReverseTranslatorTrendVariable2_EMS) { + + openstudio::path idfPath = toPath("./EMS_TrendVariable2.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_TrendVariable2T.osm"), true); + } \ No newline at end of file diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 778e91b3d4c..1b1db0c93dc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -19,6 +19,10 @@ #include "EnergyManagementSystemOutputVariable.hpp" #include "EnergyManagementSystemOutputVariable_Impl.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemProgram_Impl.hpp" +#include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemSubroutine_Impl.hpp" #include #include @@ -106,8 +110,15 @@ namespace detail { return result; } - bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { - bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, eMSProgramorSubroutineName); + bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, program.handle()); + OS_ASSERT(result); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); + OS_ASSERT(result); return result; } @@ -182,8 +193,12 @@ bool EnergyManagementSystemOutputVariable::setUpdateFrequency(const std::string& return getImpl()->setUpdateFrequency(updateFrequency); } -bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName) { - return getImpl()->setEMSProgramorSubroutineName(eMSProgramorSubroutineName); +bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + return getImpl()->setEMSProgramorSubroutineName(program); +} + +bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + return getImpl()->setEMSProgramorSubroutineName(subroutine); } void EnergyManagementSystemOutputVariable::resetEMSProgramorSubroutineName() { diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index af6809050ef..d2f561df640 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -22,6 +22,8 @@ #include #include "ModelObject.hpp" +#include "EnergyManagementSystemProgram.hpp" +#include "EnergyManagementSystemSubroutine.hpp" namespace openstudio { namespace model { @@ -73,7 +75,9 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + + bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); void resetEMSProgramorSubroutineName(); diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp index 51abbe4fb77..04a9f969a84 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp @@ -80,7 +80,9 @@ namespace detail { bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const std::string& eMSProgramorSubroutineName); + bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + + bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); void resetEMSProgramorSubroutineName(); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 0359eafa420..74b4a7a9a94 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -30,6 +30,7 @@ #include "../EnergyManagementSystemActuator.hpp" #include "../EnergyManagementSystemGlobalVariable.hpp" #include "../EnergyManagementSystemProgram.hpp" +#include "../EnergyManagementSystemSubroutine.hpp" #include "../EnergyManagementSystemOutputVariable.hpp" #include "../OutputVariable.hpp" #include "../OutputVariable_Impl.hpp" @@ -115,14 +116,14 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) //program or subroutine name bool init = outvar.eMSProgramorSubroutineName().is_initialized(); EXPECT_EQ(false, init); - bool setprogram = outvar.setEMSProgramorSubroutineName("program name"); + //bool setprogram = outvar.setEMSProgramorSubroutineName("program name"); //expect false since program doesnt exist - EXPECT_EQ(false, setprogram); + //EXPECT_EQ(false, setprogram); // add program EnergyManagementSystemProgram program(model); program.setName("program 1"); - setprogram = outvar.setEMSProgramorSubroutineName("program_1"); + bool setprogram = outvar.setEMSProgramorSubroutineName(program); EXPECT_EQ(true, setprogram); EXPECT_EQ("program_1", outvar.eMSProgramorSubroutineName().get()); From 4a7526d49e1b886c0e6d7f016228ca95e7927c56 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 21 Sep 2016 18:02:58 -0600 Subject: [PATCH 121/159] debugging RT --- ...yManagementSystemMeteredOutputVariable.cpp | 36 ++++++++--- ...teEnergyManagementSystemOutputVariable.cpp | 20 +++++- .../model/EnergyManagementSystemActuator.cpp | 8 +-- .../EnergyManagementSystemGlobalVariable.cpp | 64 +------------------ ...EnergyManagementSystemInternalVariable.cpp | 6 +- ...yManagementSystemMeteredOutputVariable.cpp | 29 ++++----- .../EnergyManagementSystemOutputVariable.cpp | 12 ++-- .../model/EnergyManagementSystemSensor.cpp | 2 +- 8 files changed, 73 insertions(+), 104 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 9bd08b5f9af..30536a86b27 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -25,6 +25,8 @@ #include "../../model/EnergyManagementSystemProgram_Impl.hpp" #include "../../model/EnergyManagementSystemSubroutine.hpp" #include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -51,14 +53,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut openstudio::model::EnergyManagementSystemMeteredOutputVariable emsOutputVariable(m_model); emsOutputVariable.setName(*s); - s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName); - if (!s) { - LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); - return boost::none; - } else { - emsOutputVariable.setEMSVariableName(*s); - } - s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency); if (!s) { LOG(Error, emsOutputVariable.nameString() + ": UpdateFrequency not set"); @@ -114,11 +108,35 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut EnergyManagementSystemSubroutine subroutine = modelObject.get().cast(); emsOutputVariable.setEMSProgramorSubroutineName(subroutine); } - return emsOutputVariable; + break; } } } + + s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName); + if (!s) { + LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); + return boost::none; + } else { + Workspace workspace = workspaceObject.workspace(); + for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + if (modelObject.get().cast().name() == s) { + emsOutputVariable.setEMSVariableName(*s); + return emsOutputVariable; + } + } + } + for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + emsOutputVariable.setEMSVariableName(*s); + return emsOutputVariable; + } + } + } return emsOutputVariable; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp index 2b33ef092aa..1cf389ccde9 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -25,6 +25,8 @@ #include "../../model/EnergyManagementSystemProgram_Impl.hpp" #include "../../model/EnergyManagementSystemSubroutine.hpp" #include "../../model/EnergyManagementSystemSubroutine_Impl.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable.hpp" +#include "../../model/EnergyManagementSystemGlobalVariable_Impl.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -56,7 +58,23 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); return boost::none; } else { - emsOutputVariable.setEMSVariableName(*s); + Workspace workspace = workspaceObject.workspace(); + for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + if (modelObject.get().cast().name() == s) { + emsOutputVariable.setEMSVariableName(*s); + break; + } + } + } + for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + emsOutputVariable.setEMSVariableName(*s); + break; + } + } } s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::UpdateFrequency); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 35d60009ece..5313001ffa7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -74,13 +74,13 @@ namespace detail { std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const { boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemActuator_Impl::actuatedComponentType() const { boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } @@ -90,13 +90,13 @@ namespace detail { bool EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } bool EnergyManagementSystemActuator_Impl::setActuatedComponentType(const std::string& actuatedComponentType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, actuatedComponentType); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp index f91c0540f76..f7fa239d29b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -66,51 +66,6 @@ namespace detail { return EnergyManagementSystemGlobalVariable::iddObjectType(); } - /* bool EnergyManagementSystemGlobalVariable_Impl::addVariable(const std::string& variable) { - //set global variable - bool result = false; - - WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); - result = group.setString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, variable); - - return result; - } - - bool EnergyManagementSystemGlobalVariable_Impl::removeVariable(const std::string& variable) { - //remove global variable - bool result = false; - - auto groups = extensibleGroups(); - unsigned sizeOfGroup = numExtensibleGroups(); - int i = 0; - for (auto group = groups.begin(); group != groups.end(); ++group) { - if (group->getString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, true) == variable) { - eraseExtensibleGroup(i); - i++; - result = true; - } - } - return result; - } - - std::vector EnergyManagementSystemGlobalVariable_Impl::getVariables() const { - //return vector of global variables - std::vector result; - auto groups = extensibleGroups(); - - for (auto group = groups.begin(); group != groups.end(); ++group) { - const auto & variable = group->getString(OS_EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName, true); - OS_ASSERT(variable); - result.push_back(variable.get()); - } - return result; - } - - void EnergyManagementSystemGlobalVariable_Impl::eraseVariables() { - //erase all Variables in this global variable object - clearExtensibleGroups(); - } - */ } // detail EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const std::string& variableName, const Model& model) @@ -118,30 +73,13 @@ EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const { OS_ASSERT(getImpl()); bool test = getImpl()->setName(variableName); - OS_ASSERT(test); + //OS_ASSERT(test); } IddObjectType EnergyManagementSystemGlobalVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_GlobalVariable); } -/* -bool EnergyManagementSystemGlobalVariable::addVariable(const std::string& variable) { - return getImpl()->addVariable(variable); -} - -bool EnergyManagementSystemGlobalVariable::removeVariable(const std::string& variable) { - return getImpl()->removeVariable(variable); -} - -std::vector EnergyManagementSystemGlobalVariable::getVariables() const { - return getImpl()->getVariables(); -} - -void EnergyManagementSystemGlobalVariable::eraseVariables() { - getImpl()->eraseVariables(); -} -*/ /// @cond EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp index 52460c0b8fd..2b4f8c1420e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -70,7 +70,7 @@ namespace detail { std::string EnergyManagementSystemInternalVariable_Impl::internalDataType() const { boost::optional value = getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } @@ -82,12 +82,12 @@ namespace detail { void EnergyManagementSystemInternalVariable_Impl::resetInternalDataIndexKeyName() { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } bool EnergyManagementSystemInternalVariable_Impl::setInternalDataType(const std::string& internalDataType) { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType, internalDataType); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 43bfc708fff..10781ab7628 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -71,13 +71,13 @@ namespace detail { std::string EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::updateFrequency() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } @@ -87,19 +87,19 @@ namespace detail { std::string EnergyManagementSystemMeteredOutputVariable_Impl::resourceType() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::ResourceType,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::groupType() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::GroupType,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::endUseCategory() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } @@ -113,7 +113,6 @@ namespace detail { void EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, eMSVariableName); - OS_ASSERT(result); } bool EnergyManagementSystemMeteredOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) { @@ -123,19 +122,19 @@ namespace detail { bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, program.handle()); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } bool EnergyManagementSystemMeteredOutputVariable_Impl::setResourceType(const std::string& resourceType) { @@ -155,22 +154,22 @@ namespace detail { void EnergyManagementSystemMeteredOutputVariable_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, endUseSubcategory); - OS_ASSERT(result); + //OS_ASSERT(result); } void EnergyManagementSystemMeteredOutputVariable_Impl::resetEndUseSubcategory() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } void EnergyManagementSystemMeteredOutputVariable_Impl::setUnits(const std::string& units) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, units); - OS_ASSERT(result); + //OS_ASSERT(result); } void EnergyManagementSystemMeteredOutputVariable_Impl::resetUnits() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } } // detail @@ -182,13 +181,9 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput bool ok = true; ok = setUpdateFrequency("SystemTimestep"); - OS_ASSERT(ok); ok = setResourceType("Electricity"); - OS_ASSERT(ok); ok = setGroupType("Building"); - OS_ASSERT(ok); ok = setEndUseCategory("Fans"); - OS_ASSERT(ok); } IddObjectType EnergyManagementSystemMeteredOutputVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 1b1db0c93dc..fa7b1416a30 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -71,19 +71,19 @@ namespace detail { std::string EnergyManagementSystemOutputVariable_Impl::eMSVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemOutputVariable_Impl::typeofDatainVariable() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemOutputVariable_Impl::updateFrequency() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency,true); - OS_ASSERT(value); + //OS_ASSERT(value); return value.get(); } @@ -112,7 +112,7 @@ namespace detail { bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, program.handle()); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } @@ -124,7 +124,7 @@ namespace detail { void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } bool EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { @@ -134,7 +134,7 @@ namespace detail { void EnergyManagementSystemOutputVariable_Impl::resetUnits() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, ""); - OS_ASSERT(result); + //OS_ASSERT(result); } } // detail diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 3967ce37211..4d683f35989 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -93,7 +93,7 @@ namespace detail { bool EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, keyName); - OS_ASSERT(result); + //OS_ASSERT(result); return result; } From bfc48040efe7479a6aaf616faa59f4a0aa5e6370 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 22 Sep 2016 09:25:17 -0600 Subject: [PATCH 122/159] adding RT/EMSSubroutine to CMakeLists.txt --- openstudiocore/src/energyplus/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/openstudiocore/src/energyplus/CMakeLists.txt b/openstudiocore/src/energyplus/CMakeLists.txt index 4ad56507dde..0d6fbdb4ba4 100644 --- a/openstudiocore/src/energyplus/CMakeLists.txt +++ b/openstudiocore/src/energyplus/CMakeLists.txt @@ -383,6 +383,7 @@ set(${target_name}_src ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp + ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp ReverseTranslator/ReverseTranslateEvaporativeCoolerDirectResearchSpecial.cpp ReverseTranslator/ReverseTranslateEvaporativeFluidCoolerSingleSpeed.cpp From 27af9ac3efcea0fd58f6dcc4325eef3ff288783b Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 22 Sep 2016 11:09:52 -0600 Subject: [PATCH 123/159] cleanup EMS ReverseTranslator --- ...ranslateEnergyManagementSystemActuator.cpp | 9 ++++---- ...agementSystemConstructionIndexVariable.cpp | 9 ++++---- ...agementSystemCurveOrTableIndexVariable.cpp | 9 ++++---- ...EnergyManagementSystemInternalVariable.cpp | 1 + ...yManagementSystemMeteredOutputVariable.cpp | 5 +++-- ...teEnergyManagementSystemOutputVariable.cpp | 9 ++++---- ...TranslateEnergyManagementSystemProgram.cpp | 10 ++------- ...yManagementSystemProgramCallingManager.cpp | 3 ++- ...eTranslateEnergyManagementSystemSensor.cpp | 20 ++++++++++------- ...nslateEnergyManagementSystemSubroutine.cpp | 10 ++------- ...ateEnergyManagementSystemTrendVariable.cpp | 5 +++++ .../src/energyplus/Test/EMS_GTest.cpp | 22 +++++++++++++++++++ 12 files changed, 69 insertions(+), 43 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp index 0970541be47..1c7e77785cf 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp @@ -39,13 +39,15 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(c return boost::none; } - OptionalString s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); - if(!s){ + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); + if(!s1){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_Actuator has no name"); return boost::none; } - s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName); if (!s) { + LOG(Error, workspaceObject.nameString() + ": has no ActuatedComponentUniqueName"); return boost::none; } @@ -56,7 +58,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(c boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { openstudio::model::EnergyManagementSystemActuator emsActuator(modelObject.get()); - OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); emsActuator.setName(*s1); emsActuator.setActuatedComponent(modelObject.get()); s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp index 5d136bf0ded..b314d4d69e6 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -39,13 +39,15 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructi return boost::none; } - OptionalString s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name); - if(!s){ + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name); + if(!s1){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_ConstructionIndexVariable has no Name"); return boost::none; } - s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); + OptionalString s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName); if (!s) { + LOG(Error, workspaceObject.nameString() + ": has no ConstructionObjectName"); return boost::none; } @@ -56,7 +58,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructi boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model); - OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name); emsConstructionIndexVariable.setName(*s1); emsConstructionIndexVariable.setConstructionObject(modelObject.get()); return emsConstructionIndexVariable; diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp index 83d3fa4caa5..68a6d5634d5 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -39,13 +39,15 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTab return boost::none; } - OptionalString s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name); - if(!s){ + OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name); + if(!s1){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_CurveOrTableIndexVariable has no name"); return boost::none; } - s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); + OptionalString s = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); if (!s) { + LOG(Error, workspaceObject.nameString() + ": has no CurveorTableObjectName"); return boost::none; } @@ -56,7 +58,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTab boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { openstudio::model::EnergyManagementSystemCurveOrTableIndexVariable emsCurveOrTableIndexVariable(m_model); - OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_CurveOrTableIndexVariableFields::Name); emsCurveOrTableIndexVariable.setName(*s1); emsCurveOrTableIndexVariable.setCurveorTableObject(modelObject.get()); return emsCurveOrTableIndexVariable; diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp index 3b8bd2916ef..1419ceb134f 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemInternalVariable.cpp @@ -41,6 +41,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemInternalVa OptionalString s = workspaceObject.getString(EnergyManagementSystem_InternalVariableFields::Name); if(!s){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_InternalVariable has no Name."); return boost::none; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 30536a86b27..937e6875217 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -47,7 +47,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut OptionalString s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::Name); if(!s){ - LOG(Error, "EnergyManagementSystem_MeteredOutputVariable Name not set"); + LOG(Error, "WorkspaceObject EnergyManagementSystem_MeteredOutputVariable has no Name"); return boost::none; } openstudio::model::EnergyManagementSystemMeteredOutputVariable emsOutputVariable(m_model); @@ -111,7 +111,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut break; } } - } s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName); @@ -120,6 +119,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut return boost::none; } else { Workspace workspace = workspaceObject.workspace(); + //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { @@ -129,6 +129,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut } } } + //look for name match on other (EMS) objects. for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp index 1cf389ccde9..8f202e8d0c9 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -47,7 +47,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari OptionalString s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Name); if (!s) { - LOG(Error, "EnergyManagementSystem_OutputVariable Name not set"); + LOG(Error, "EnergyManagementSystem_OutputVariable has no Name"); return boost::none; } openstudio::model::EnergyManagementSystemOutputVariable emsOutputVariable(m_model); @@ -59,6 +59,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari return boost::none; } else { Workspace workspace = workspaceObject.workspace(); + //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { @@ -68,6 +69,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari } } } + //look for name match on other (EMS) objects. for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { @@ -104,15 +106,14 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { - if (modelObject.get().iddObjectType() == IddObjectType::EnergyManagementSystem_Program) { + if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Program) { emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); - } else if (modelObject.get().iddObjectType() == IddObjectType::EnergyManagementSystem_Subroutine) { + } else if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Subroutine) { emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); } return emsOutputVariable; } } - } return emsOutputVariable; diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp index 1f2ff29ab39..f699a40c99e 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp @@ -44,20 +44,14 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgram(co OptionalString s = workspaceObject.getString(EnergyManagementSystem_ProgramFields::Name); if(!s){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_Program has no Name"); return boost::none; } openstudio::model::EnergyManagementSystemProgram emsProgram(m_model); + emsProgram.setName(*s); - if (s) { - emsProgram.setName(*s); - } - - //for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { - //emsProgram.pushExtensibleGroup(eg.fields()); - //} unsigned n = workspaceObject.numExtensibleGroups(); - //OptionalWorkspaceObject line; OptionalString line; for (unsigned i = 0; i < n; ++i) { line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp index 1837e8a8c93..d589156d7e9 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp @@ -46,6 +46,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCal OptionalString s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::Name); if(!s){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_ProgramCallingManager has no name"); return boost::none; } @@ -54,6 +55,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCal s = workspaceObject.getString(EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); if (!s) { + LOG(Error, emsProgramCallingManager.nameString() + ": has no EnergyPlusModelCallingPoint"); return boost::none; } else { emsProgramCallingManager.setCallingPoint(*s); @@ -73,7 +75,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCal } } } - return emsProgramCallingManager; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp index 034b5232c78..fe1d3e4af47 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp @@ -41,19 +41,19 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con OptionalString s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Name); if(!s){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_Sensor has no Name"); return boost::none; } openstudio::model::EnergyManagementSystemSensor emsSensor(m_model); + emsSensor.setName(*s); - if (s) { - emsSensor.setName(*s); - } Workspace workspace = workspaceObject.workspace(); s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName); if (s) { + //look for Output:Variables named *s for (const WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::Output_Variable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { @@ -66,12 +66,16 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con } } } + //look for Output:Meters named *s for (const WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::Output_Meter)) { - boost::optional outvar = wsObject.optionalCast(); - if (outvar) { - if (outvar.get().name() == s) { - emsSensor.setOutputMeter(wsObject.cast()); - break; + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + if (modelObject) { + boost::optional outvar = modelObject->optionalCast(); + if (outvar) { + if (outvar.get().name() == s) { + emsSensor.setOutputMeter(outvar.get()); + break; + } } } } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp index 58eea059fcb..704a71cafdb 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp @@ -44,20 +44,14 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSubroutine OptionalString s = workspaceObject.getString(EnergyManagementSystem_SubroutineFields::Name); if (!s) { + LOG(Error, "WorkspaceObject EnergyManagementSystem_Subroutine has no Name"); return boost::none; } openstudio::model::EnergyManagementSystemSubroutine emsProgram(m_model); + emsProgram.setName(*s); - if (s) { - emsProgram.setName(*s); - } - - //for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { - //emsProgram.pushExtensibleGroup(eg.fields()); - //} unsigned n = workspaceObject.numExtensibleGroups(); - //OptionalWorkspaceObject line; OptionalString line; for (unsigned i = 0; i < n; ++i) { line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp index 03c2c123404..3cf979e2a2a 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp @@ -43,6 +43,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria OptionalString s = workspaceObject.getString(EnergyManagementSystem_TrendVariableFields::Name); if(!s){ + LOG(Error, "WorkspaceObject EnergyManagementSystem_TrendVariable has no Name"); return boost::none; } @@ -51,6 +52,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria boost::optional i = workspaceObject.getInt(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged); if (!i) { + LOG(Error, emsTrendVariable.nameString() + ": NumberofTimestepstobeLogged not set"); return boost::none; } else { emsTrendVariable.setNumberofTimestepstobeLogged(*i); @@ -58,9 +60,11 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria s = workspaceObject.getString(EnergyManagementSystem_TrendVariableFields::EMSVariableName); if (!s) { + LOG(Error, emsTrendVariable.nameString() + ": EMSVariableName not set"); return boost::none; } else { Workspace workspace = workspaceObject.workspace(); + //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { @@ -70,6 +74,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria } } } + //look for name match on other (EMS) objects. for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index aa2d523d1de..f17032660ba 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -245,6 +245,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { workspace.save(toPath("./EMS_sensor2.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorSensor2_EMS) { + + openstudio::path idfPath = toPath("./EMS_sensor2.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_sensor2T.osm"), true); +} + TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { Model model; @@ -283,6 +294,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { workspace.save(toPath("./EMS_sensor_meter.idf"), true); } +TEST_F(EnergyPlusFixture, ReverseTranslatorSensor_Meter_EMS) { + + openstudio::path idfPath = toPath("./EMS_sensor_meter.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_sensor_meterT.osm"), true); + +} TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { Model model; From 6c5740011c2b1169c869e6f77f36b5ae26534098 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 22 Sep 2016 20:29:05 -0600 Subject: [PATCH 124/159] EMS updates and cleanup --- openstudiocore/resources/model/OpenStudio.idd | 80 +++++++++---------- ...agementSystemConstructionIndexVariable.cpp | 2 +- .../model/EnergyManagementSystemActuator.cpp | 25 ++++-- ...agementSystemConstructionIndexVariable.cpp | 13 ++- ...agementSystemConstructionIndexVariable.hpp | 2 + ...agementSystemCurveOrTableIndexVariable.cpp | 14 +++- ...agementSystemCurveOrTableIndexVariable.hpp | 3 + .../EnergyManagementSystemGlobalVariable.cpp | 7 +- .../EnergyManagementSystemGlobalVariable.hpp | 8 -- ...rgyManagementSystemGlobalVariable_Impl.hpp | 8 -- ...EnergyManagementSystemInternalVariable.cpp | 9 +-- ...yManagementSystemMeteredOutputVariable.cpp | 47 +++++------ ...yManagementSystemMeteredOutputVariable.hpp | 6 +- ...gementSystemMeteredOutputVariable_Impl.hpp | 6 +- .../EnergyManagementSystemOutputVariable.cpp | 10 +-- .../model/EnergyManagementSystemProgram.cpp | 3 - ...yManagementSystemProgramCallingManager.cpp | 13 --- ...yManagementSystemProgramCallingManager.hpp | 2 - ...gementSystemProgramCallingManager_Impl.hpp | 2 - .../model/EnergyManagementSystemSensor.cpp | 24 +++++- .../model/EnergyManagementSystemSensor.hpp | 4 + .../EnergyManagementSystemSubroutine.cpp | 4 - .../EnergyManagementSystemTrendVariable.cpp | 4 +- ...tSystemConstructionIndexVariable_GTest.cpp | 2 +- ...tSystemCurveOrTableIndexVariable_GTest.cpp | 2 +- 25 files changed, 157 insertions(+), 143 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 91ee2dd8869..54f5ba67bf9 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26406,17 +26406,17 @@ OS:EnergyManagementSystem:Sensor, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames \reference AllObjects - A3 , \field Output Variable or Output Meter Index Key Name + A3, \field Output Variable or Output Meter Index Key Name \type alpha \note key name listed here will override key name in Output:Variable or Output:Meter - A4 ; \field Output Variable or Output Meter Name + A4; \field Output Variable or Output Meter Name \required-field \type object-list \object-list OutputVariableMeterNames @@ -26427,21 +26427,21 @@ OS:EnergyManagementSystem:Actuator, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames \reference AllObjects - A3 , \field Actuated Component Name + A3, \field Actuated Component Name \required-field \type object-list \object-list AllObjects - A4 , \field Actuated Component Type + A4, \field Actuated Component Type \required-field \type alpha - A5 ; \field Actuated Component Control Type + A5; \field Actuated Component Control Type \required-field \type alpha @@ -26454,12 +26454,12 @@ OS:EnergyManagementSystem:ProgramCallingManager, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \reference ErlProgramCallingManagerNames \note No spaces allowed in names for ErlProgramCallingManagerNames - A3 , \field EnergyPlus Model Calling Point + A3, \field EnergyPlus Model Calling Point \type choice \key BeginNewEnvironment \key AfterNewEnvironmentWarmUpIsComplete @@ -26476,7 +26476,7 @@ OS:EnergyManagementSystem:ProgramCallingManager, \key AfterComponentInputReadIn \key UserDefinedComponentModel \key UnitarySystemSizing - A4 ; \field Program Name + A4; \field Program Name \begin-extensible \required-field \type object-list @@ -26491,13 +26491,13 @@ OS:EnergyManagementSystem:Program, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \reference ErlProgramNames \reference ErlProgramSubroutineNames \note No spaces allowed in names for ErlProgramNames - A3 ; \field Program Line + A3; \field Program Line \begin-extensible \type alpha \required-field @@ -26510,13 +26510,13 @@ OS:EnergyManagementSystem:Subroutine, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \reference ErlSubroutineNames \reference ErlProgramSubroutineNames \note No spaces allowed in names for ErlSubroutineNames - A3 ; \field Program Line + A3; \field Program Line \begin-extensible \type alpha \required-field @@ -26528,7 +26528,7 @@ OS:EnergyManagementSystem:GlobalVariable, A1, \field Handle \type handle \required-field - A2 ; \field Name + A2; \field Name \required-field \type alpha \reference ErlVariableNames @@ -26540,30 +26540,30 @@ OS:EnergyManagementSystem:OutputVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \retaincase - A3 , \field EMS Variable Name + A3, \field EMS Variable Name \required-field \type object-list \object-list ErlVariableNames \note must be an acceptable EMS variable - A4 , \field Type of Data in Variable + A4, \field Type of Data in Variable \required-field \type choice \key Averaged \key Summed - A5 , \field Update Frequency + A5, \field Update Frequency \required-field \type choice \key ZoneTimestep \key SystemTimestep - A6 , \field EMS Program or Subroutine Name + A6, \field EMS Program or Subroutine Name \type object-list \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables - A7 ; \field Units + A7; \field Units \note optional but will result in dimensionless units for blank \note EnergyPlus units are standard SI units \type alpha @@ -26574,25 +26574,25 @@ OS:EnergyManagementSystem:MeteredOutputVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \retaincase - A3 , \field EMS Variable Name + A3, \field EMS Variable Name \required-field \type object-list \object-list ErlVariableNames \note must be an acceptable EMS variable, no spaces - A4 , \field Update Frequency + A4, \field Update Frequency \required-field \type choice \key ZoneTimestep \key SystemTimestep - A5 , \field EMS Program or Subroutine Name + A5, \field EMS Program or Subroutine Name \type object-list \object-list ErlProgramSubroutineNames \note optional for global scope variables, required for local scope variables - A6 , \field Resource Type + A6, \field Resource Type \required-field \note choose the type of fuel, water, electricity, pollution or heat rate that should be metered. \type choice @@ -26619,7 +26619,7 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \key ElectricityProducedOnSite \key SolarWaterHeating \key SolarAirHeating - A7 , \field Group Type + A7, \field Group Type \note choose a general classification, building (internal services), HVAC (air systems), or plant (hydronic systems), or system \type choice \required-field @@ -26627,7 +26627,7 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \key HVAC \key Plant \key System - A8 , \field End-Use Category + A8, \field End-Use Category \note choose how the metered output should be classified for end-use category \required-field \type choice @@ -26652,10 +26652,10 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \key Baseboard \key HeatRecoveryForCooling \key HeatRecoveryForHeating - A9 , \field End-Use Subcategory + A9, \field End-Use Subcategory \type alpha \note enter a user-defined subcategory for this metered output - A10 ; \field Units + A10; \field Units \note optional but will result in dimensionless units for blank \note EnergyPlus units are standard SI units \type alpha @@ -26667,17 +26667,17 @@ OS:EnergyManagementSystem:TrendVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames - A3 , \field EMS Variable Name + A3, \field EMS Variable Name \required-field \type object-list \object-list ErlVariableNames \note must be a global scope EMS variable - N1 ; \field Number of Timesteps to be Logged + N1; \field Number of Timesteps to be Logged \required-field \type integer \minimum 1 @@ -26688,15 +26688,15 @@ OS:EnergyManagementSystem:InternalVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames - A3 , \field Internal Data Index Key Name + A3, \field Internal Data Index Key Name \type alpha - A4 ; \field Internal Data Type + A4; \field Internal Data Type \required-field \type alpha @@ -26706,13 +26706,13 @@ OS:EnergyManagementSystem:CurveOrTableIndexVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames - A3 ; \field Curve or Table Object Name + A3; \field Curve or Table Object Name \type object-list \object-list AllCurves \required-field @@ -26723,13 +26723,13 @@ OS:EnergyManagementSystem:ConstructionIndexVariable, A1, \field Handle \type handle \required-field - A2 , \field Name + A2, \field Name \required-field \type alpha \note This name becomes a variable for use in Erl programs \note No spaces allowed in names for ErlVariableNames \reference ErlVariableNames - A3 ; \field Construction Object Name + A3; \field Construction Object Name \type object-list \object-list ConstructionNames \required-field diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp index b314d4d69e6..d8eac962056 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -59,7 +59,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructi if (modelObject) { openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model); emsConstructionIndexVariable.setName(*s1); - emsConstructionIndexVariable.setConstructionObject(modelObject.get()); + //emsConstructionIndexVariable.setConstructionObject(modelObject.get()); return emsConstructionIndexVariable; } } diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 5313001ffa7..9a2ee90fd7e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -74,14 +74,20 @@ namespace detail { std::string EnergyManagementSystemActuator_Impl::actuatedComponentControlType() const { boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType,true); - //OS_ASSERT(value); - return value.get(); + if (value) { + return value.get(); + } else { + return ""; + } } std::string EnergyManagementSystemActuator_Impl::actuatedComponentType() const { boost::optional value = getString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, true); - //OS_ASSERT(value); - return value.get(); + if (value) { + return value.get(); + } else { + return ""; + } } bool EnergyManagementSystemActuator_Impl::setActuatedComponent(const ModelObject& modelObject) { @@ -90,13 +96,11 @@ namespace detail { bool EnergyManagementSystemActuator_Impl::setActuatedComponentControlType(const std::string& actuatedComponentControlType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, actuatedComponentControlType); - //OS_ASSERT(result); return result; } bool EnergyManagementSystemActuator_Impl::setActuatedComponentType(const std::string& actuatedComponentType) { bool result = setString(OS_EnergyManagementSystem_ActuatorFields::ActuatedComponentType, actuatedComponentType); - //OS_ASSERT(result); return result; } @@ -107,11 +111,20 @@ EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject { OS_ASSERT(getImpl()); setActuatedComponent(modelObject); + //TODO set below to some appropriate default that depends on the modelObject::IddType + //setActuatedComponentControlType(); + //setActuatedComponentType(); } EnergyManagementSystemActuator::EnergyManagementSystemActuator(const Model& model) : ModelObject(EnergyManagementSystemActuator::iddObjectType(), model) { OS_ASSERT(getImpl()); + //This constructor is used in the ReverseTranslator when the ActuatedComponent doesnt Reverse Translate. + //In that case, a generic Actuator is created with ActuatedComponent blank (but the old value is in a comment) + //TODO setActuatedComponent to a default modelObject. + //TODO set below to some appropriate default that depends on the modelObject::IddType + //setActuatedComponentControlType(); + //setActuatedComponentType(); } IddObjectType EnergyManagementSystemActuator::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp index d3d97b72051..79e6f38c21d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -87,10 +87,21 @@ namespace detail { } // detail -EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model) +EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model, Construction& construction) : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + bool ok = setConstructionObject(construction); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s Construction to " + << construction.briefDescription() << "."); + } +} + +EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model) + : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); } IddObjectType EnergyManagementSystemConstructionIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp index 9b3dc27efd8..8d5e4caf345 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp @@ -41,6 +41,8 @@ class MODEL_API EnergyManagementSystemConstructionIndexVariable : public ModelOb /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemConstructionIndexVariable(const Model& model, Construction& construction); + explicit EnergyManagementSystemConstructionIndexVariable(const Model& model); virtual ~EnergyManagementSystemConstructionIndexVariable() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp index ae060d17515..8769065e54b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -19,6 +19,7 @@ #include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" #include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "Curve.hpp" // TODO: Check the following class names against object getters and setters. //#include "AllCurves.hpp" @@ -87,10 +88,21 @@ namespace detail { } // detail -EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model) +EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, Curve& curve) : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + bool ok = setCurveorTableObject(curve); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s Curve to " + << curve.briefDescription() << "."); + } +} + +EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model) + : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); } IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp index c023b84abbd..4cc08642ee7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp @@ -22,6 +22,7 @@ #include #include "ModelObject.hpp" +#include "Curve.hpp" namespace openstudio { namespace model { @@ -41,6 +42,8 @@ class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable : public ModelOb /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, Curve& curve); //Does Curve cover all object-list AllCurves? + explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model); virtual ~EnergyManagementSystemCurveOrTableIndexVariable() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp index f7fa239d29b..74f3b8cf717 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -72,8 +72,11 @@ EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const : ModelObject(EnergyManagementSystemGlobalVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - bool test = getImpl()->setName(variableName); - //OS_ASSERT(test); + bool ok = getImpl()->setName(variableName); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s Name to " << variableName << "."); + } } IddObjectType EnergyManagementSystemGlobalVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp index acf6cb23aa1..b59ba9ba95e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -49,18 +49,10 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { /** @name Getters */ //@{ - //std::vector getVariables() const; - //@} /** @name Setters */ //@{ - //bool addVariable(const std::string& variable); - - //bool removeVariable(const std::string& variable); - - //void eraseVariables(); - //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp index 4c4a5c37ff3..e276332b7cd 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable_Impl.hpp @@ -60,18 +60,10 @@ namespace detail { /** @name Getters */ //@{ - //std::vector getVariables() const; - //@} /** @name Setters */ //@{ - //bool addVariable(const std::string& variable); - - //bool removeVariable(const std::string& variable); - - //void eraseVariables(); - //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp index 2b4f8c1420e..73a4738bc04 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -70,24 +70,21 @@ namespace detail { std::string EnergyManagementSystemInternalVariable_Impl::internalDataType() const { boost::optional value = getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType,true); - //OS_ASSERT(value); return value.get(); } bool EnergyManagementSystemInternalVariable_Impl::setInternalDataIndexKeyName(const std::string& internalDataIndexKeyName) { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, internalDataIndexKeyName); - OS_ASSERT(result); return result; } void EnergyManagementSystemInternalVariable_Impl::resetInternalDataIndexKeyName() { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } bool EnergyManagementSystemInternalVariable_Impl::setInternalDataType(const std::string& internalDataType) { bool result = setString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataType, internalDataType); - //OS_ASSERT(result); return result; } @@ -97,9 +94,7 @@ EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(c : ModelObject(EnergyManagementSystemInternalVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. - // setInternalDataType(); + //TODO setInternalDataType to valid EIO default value } IddObjectType EnergyManagementSystemInternalVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 10781ab7628..70ba2f99a04 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -71,13 +71,11 @@ namespace detail { std::string EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName,true); - //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::updateFrequency() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency,true); - //OS_ASSERT(value); return value.get(); } @@ -87,19 +85,16 @@ namespace detail { std::string EnergyManagementSystemMeteredOutputVariable_Impl::resourceType() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::ResourceType,true); - //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::groupType() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::GroupType,true); - //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemMeteredOutputVariable_Impl::endUseCategory() const { boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory,true); - //OS_ASSERT(value); return value.get(); } @@ -111,8 +106,9 @@ namespace detail { return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units,true); } - void EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, eMSVariableName); + return result; } bool EnergyManagementSystemMeteredOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) { @@ -122,19 +118,17 @@ namespace detail { bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, program.handle()); - //OS_ASSERT(result); return result; } bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); - //OS_ASSERT(result); return result; } void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } bool EnergyManagementSystemMeteredOutputVariable_Impl::setResourceType(const std::string& resourceType) { @@ -152,24 +146,24 @@ namespace detail { return result; } - void EnergyManagementSystemMeteredOutputVariable_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) { + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, endUseSubcategory); - //OS_ASSERT(result); + return result; } void EnergyManagementSystemMeteredOutputVariable_Impl::resetEndUseSubcategory() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } - void EnergyManagementSystemMeteredOutputVariable_Impl::setUnits(const std::string& units) { + bool EnergyManagementSystemMeteredOutputVariable_Impl::setUnits(const std::string& units) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, units); - //OS_ASSERT(result); + return result; } void EnergyManagementSystemMeteredOutputVariable_Impl::resetUnits() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } } // detail @@ -178,12 +172,11 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - - bool ok = true; - ok = setUpdateFrequency("SystemTimestep"); - ok = setResourceType("Electricity"); - ok = setGroupType("Building"); - ok = setEndUseCategory("Fans"); + //TODO setEMSVariableName to a valid default + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); } IddObjectType EnergyManagementSystemMeteredOutputVariable::iddObjectType() { @@ -242,8 +235,8 @@ boost::optional EnergyManagementSystemMeteredOutputVariable::units( return getImpl()->units(); } -void EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { - getImpl()->setEMSVariableName(eMSVariableName); +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + return getImpl()->setEMSVariableName(eMSVariableName); } bool EnergyManagementSystemMeteredOutputVariable::setUpdateFrequency(const std::string& updateFrequency) { @@ -274,16 +267,16 @@ bool EnergyManagementSystemMeteredOutputVariable::setEndUseCategory(const std::s return getImpl()->setEndUseCategory(endUseCategory); } -void EnergyManagementSystemMeteredOutputVariable::setEndUseSubcategory(const std::string& endUseSubcategory) { - getImpl()->setEndUseSubcategory(endUseSubcategory); +bool EnergyManagementSystemMeteredOutputVariable::setEndUseSubcategory(const std::string& endUseSubcategory) { + return getImpl()->setEndUseSubcategory(endUseSubcategory); } void EnergyManagementSystemMeteredOutputVariable::resetEndUseSubcategory() { getImpl()->resetEndUseSubcategory(); } -void EnergyManagementSystemMeteredOutputVariable::setUnits(const std::string& units) { - getImpl()->setUnits(units); +bool EnergyManagementSystemMeteredOutputVariable::setUnits(const std::string& units) { + return getImpl()->setUnits(units); } void EnergyManagementSystemMeteredOutputVariable::resetUnits() { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index e0fbaa19cb7..fced7e5231f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -79,7 +79,7 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setUpdateFrequency(const std::string& updateFrequency); @@ -95,11 +95,11 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject bool setEndUseCategory(const std::string& endUseCategory); - void setEndUseSubcategory(const std::string& endUseSubcategory); + bool setEndUseSubcategory(const std::string& endUseSubcategory); void resetEndUseSubcategory(); - void setUnits(const std::string& units); + bool setUnits(const std::string& units); void resetUnits(); diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp index 3747f55e734..b02a0ad4e19 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp @@ -82,7 +82,7 @@ namespace detail { /** @name Setters */ //@{ - void setEMSVariableName(const std::string& eMSVariableName); + bool setEMSVariableName(const std::string& eMSVariableName); bool setUpdateFrequency(const std::string& updateFrequency); @@ -98,11 +98,11 @@ namespace detail { bool setEndUseCategory(const std::string& endUseCategory); - void setEndUseSubcategory(const std::string& endUseSubcategory); + bool setEndUseSubcategory(const std::string& endUseSubcategory); void resetEndUseSubcategory(); - void setUnits(const std::string& units); + bool setUnits(const std::string& units); void resetUnits(); diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index fa7b1416a30..2b23e854a27 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -71,19 +71,16 @@ namespace detail { std::string EnergyManagementSystemOutputVariable_Impl::eMSVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName,true); - //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemOutputVariable_Impl::typeofDatainVariable() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable,true); - //OS_ASSERT(value); return value.get(); } std::string EnergyManagementSystemOutputVariable_Impl::updateFrequency() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency,true); - //OS_ASSERT(value); return value.get(); } @@ -112,19 +109,17 @@ namespace detail { bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, program.handle()); - //OS_ASSERT(result); return result; } bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); - OS_ASSERT(result); return result; } void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } bool EnergyManagementSystemOutputVariable_Impl::setUnits(const std::string& units) { @@ -134,7 +129,7 @@ namespace detail { void EnergyManagementSystemOutputVariable_Impl::resetUnits() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::Units, ""); - //OS_ASSERT(result); + OS_ASSERT(result); } } // detail @@ -143,6 +138,7 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + //TODO setEMSVariableName to a valid default setUpdateFrequency("ZoneTimestep"); setTypeofDatainVariable("Averaged"); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 7b181cd5940..f907d0a2717 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -158,7 +158,6 @@ namespace detail { } else { result = false; } - //ok.push_back(result); ok.at(i) = result; } //check if all the programs set true @@ -228,7 +227,6 @@ namespace detail { } else { result = false; } - return result; } @@ -285,7 +283,6 @@ namespace detail { for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - //ok.push_back(result); ok.at(i) = result; } //check if all the programs set true diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 69280f0156d..ed3c227c651 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -129,13 +129,6 @@ namespace detail { clearExtensibleGroups(); } - bool EnergyManagementSystemProgramCallingManager_Impl::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { - //bool result = setString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint, callingPoint); - //TODO what is this method doing? how is it different that setProgram? - bool result = true; - return result; - } - bool EnergyManagementSystemProgramCallingManager_Impl::addProgram(const EnergyManagementSystemProgram& program) { //add program to end of vector of programs bool result = false; @@ -154,7 +147,6 @@ namespace detail { OS_ASSERT(!idfGroup.empty()); ModelExtensibleGroup group = idfGroup.cast(); result = group.setPointer(0, program.handle()); - OS_ASSERT(result); } return result; } @@ -166,7 +158,6 @@ namespace detail { for (auto &program : programs) { WorkspaceExtensibleGroup group = getObject().pushExtensibleGroup().cast(); result = group.setPointer(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName, program.handle()); - //ok.push_back(result); ok.at(OS_EnergyManagementSystem_ProgramCallingManagerExtensibleFields::ProgramName) = result; } //check if all the programs set true @@ -250,10 +241,6 @@ void EnergyManagementSystemProgramCallingManager::erasePrograms() { getImpl()->erasePrograms(); } -bool EnergyManagementSystemProgramCallingManager::insertProgram(const EnergyManagementSystemProgram& program, unsigned index) { - return getImpl()->insertProgram(program, index); -} - bool EnergyManagementSystemProgramCallingManager::addProgram(const EnergyManagementSystemProgram& program) { return getImpl()->addProgram(program); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index 924f833ca89..cf46c12669a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -70,8 +70,6 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject void erasePrograms(); - bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); - bool addProgram(const EnergyManagementSystemProgram& program); bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index b37b5f4f53b..8bf70abfdeb 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -79,8 +79,6 @@ namespace detail { void erasePrograms(); - bool insertProgram(const EnergyManagementSystemProgram& program, unsigned index); - bool addProgram(const EnergyManagementSystemProgram& program); bool setProgram(const EnergyManagementSystemProgram& program, unsigned index); diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 4d683f35989..fa43f13cade 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -93,7 +93,6 @@ namespace detail { bool EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, keyName); - //OS_ASSERT(result); return result; } @@ -117,10 +116,33 @@ namespace detail { } // detail +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, OutputVariable& outvar) + : ModelObject(EnergyManagementSystemSensor::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setOutputVariable(outvar); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s OutputVariable to " + << outvar.briefDescription() << "."); + } +} + +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar) + : ModelObject(EnergyManagementSystemSensor::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setOutputMeter(outvar); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s OutputVariable to " + << outvar.briefDescription() << "."); + } +} + EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model) : ModelObject(EnergyManagementSystemSensor::iddObjectType(),model) { OS_ASSERT(getImpl()); + //TODO setOutputVariable() on a default OutputVariable } IddObjectType EnergyManagementSystemSensor::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index 9429627e816..5a8a05e291c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -47,6 +47,10 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { explicit EnergyManagementSystemSensor(const Model& model); + explicit EnergyManagementSystemSensor(const Model& model, OutputVariable& outvar); + + explicit EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar); + virtual ~EnergyManagementSystemSensor() {} //@} diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index e76867724cc..6f7efba23f6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -155,7 +155,6 @@ namespace detail { } else { result = false; } - //ok.push_back(result); ok.at(i) = result; } //check if all the programs set true @@ -280,7 +279,6 @@ namespace detail { for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - //ok.push_back(result); ok.at(i) = result; } //check if all the programs set true @@ -375,8 +373,6 @@ EnergyManagementSystemSubroutine::EnergyManagementSystemSubroutine(const Model& : ModelObject(EnergyManagementSystemSubroutine::iddObjectType(),model) { OS_ASSERT(getImpl()); - - // TODO: Appropriately handle the following required object-list fields. } IddObjectType EnergyManagementSystemSubroutine::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index b6ff612f643..0eb84ef9575 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -66,13 +66,11 @@ namespace detail { std::string EnergyManagementSystemTrendVariable_Impl::eMSVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName,true); - OS_ASSERT(value); return value.get(); } int EnergyManagementSystemTrendVariable_Impl::numberofTimestepstobeLogged() const { boost::optional value = getInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged,true); - OS_ASSERT(value); return value.get(); } @@ -92,6 +90,8 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); + //TODO setEMSVariableName to a valid default + setNumberofTimestepstobeLogged(1); } IddObjectType EnergyManagementSystemTrendVariable::iddObjectType() { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp index 1c51bc67619..379663779ef 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp @@ -87,7 +87,7 @@ TEST_F(ModelFixture, EMS_ConstructionIndexVariable) Construction construction(layers); - EnergyManagementSystemConstructionIndexVariable emsCIV(model); + EnergyManagementSystemConstructionIndexVariable emsCIV(model, construction); emsCIV.setConstructionObject(construction); EXPECT_EQ(construction.handle(), emsCIV.constructionObject().handle()); model.save(toPath("./EMS_constructiontest.osm"), true); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp index 9a60bb5d18f..157a1f95804 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp @@ -40,7 +40,7 @@ TEST_F(ModelFixture, EMS_CurveOrTableIndexVariable) // Create a curve CurveBiquadratic c1(model); - EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model); + EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model, c1); emsCurve.setCurveorTableObject(c1); EXPECT_EQ(c1.handle(), emsCurve.curveorTableObject().handle()); model.save(toPath("./EMS_curvetest.osm"), true); From 1f2df79556369665deb4219c4e66fcbc4f5d6902 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 23 Sep 2016 10:25:06 -0600 Subject: [PATCH 125/159] EMS constructor updates --- ...anslateEnergyManagementSystemConstructionIndexVariable.cpp | 2 +- .../model/EnergyManagementSystemConstructionIndexVariable.cpp | 4 +++- .../model/EnergyManagementSystemCurveOrTableIndexVariable.cpp | 4 ++++ .../src/model/EnergyManagementSystemProgramCallingManager.cpp | 1 + .../EnergyManagementSystemConstructionIndexVariable_GTest.cpp | 2 +- .../EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp index d8eac962056..b314d4d69e6 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -59,7 +59,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructi if (modelObject) { openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model); emsConstructionIndexVariable.setName(*s1); - //emsConstructionIndexVariable.setConstructionObject(modelObject.get()); + emsConstructionIndexVariable.setConstructionObject(modelObject.get()); return emsConstructionIndexVariable; } } diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp index 79e6f38c21d..0305390f375 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -20,7 +20,6 @@ #include "EnergyManagementSystemConstructionIndexVariable.hpp" #include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" -// TODO: Check the following class names against object getters and setters. #include "Construction.hpp" #include "Construction_Impl.hpp" @@ -102,6 +101,9 @@ EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstruct EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model) : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); + Construction construction = Construction(model); + construction.setName("Generic Construction"); + setConstructionObject(construction); } IddObjectType EnergyManagementSystemConstructionIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp index 8769065e54b..b8f7f0df236 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -20,6 +20,7 @@ #include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" #include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" #include "Curve.hpp" +#include "CurveLinear.hpp" // TODO: Check the following class names against object getters and setters. //#include "AllCurves.hpp" @@ -103,6 +104,9 @@ EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTa EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model) : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); + CurveLinear curve = CurveLinear(model); + curve.setName("Generic Curve"); + setCurveorTableObject(curve); } IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index ed3c227c651..171c8b0b1e3 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -206,6 +206,7 @@ EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallin : ModelObject(EnergyManagementSystemProgramCallingManager::iddObjectType(),model) { OS_ASSERT(getImpl()); + setCallingPoint("BeginNewEnvironment"); } IddObjectType EnergyManagementSystemProgramCallingManager::iddObjectType() { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp index 379663779ef..63db55eb0d7 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemConstructionIndexVariable_GTest.cpp @@ -88,7 +88,7 @@ TEST_F(ModelFixture, EMS_ConstructionIndexVariable) Construction construction(layers); EnergyManagementSystemConstructionIndexVariable emsCIV(model, construction); - emsCIV.setConstructionObject(construction); + //emsCIV.setConstructionObject(construction); EXPECT_EQ(construction.handle(), emsCIV.constructionObject().handle()); model.save(toPath("./EMS_constructiontest.osm"), true); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp index 157a1f95804..0171f088d7b 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp @@ -41,7 +41,7 @@ TEST_F(ModelFixture, EMS_CurveOrTableIndexVariable) CurveBiquadratic c1(model); EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model, c1); - emsCurve.setCurveorTableObject(c1); + //emsCurve.setCurveorTableObject(c1); EXPECT_EQ(c1.handle(), emsCurve.curveorTableObject().handle()); model.save(toPath("./EMS_curvetest.osm"), true); } From 0cc3b6108ef7be42175c9c2544629fc928b3bdac Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 23 Sep 2016 17:34:32 -0600 Subject: [PATCH 126/159] using Boost::regex's for uid to string swap --- ...TranslateEnergyManagementSystemProgram.cpp | 71 +++++++-------- ...nslateEnergyManagementSystemSubroutine.cpp | 66 ++++++-------- .../src/energyplus/Test/EMS_GTest.cpp | 6 +- .../model/EnergyManagementSystemProgram.cpp | 89 +++++++++---------- .../EnergyManagementSystemSubroutine.cpp | 89 +++++++++---------- .../EnergyManagementSystemProgram_GTest.cpp | 63 +++++++++++++ 6 files changed, 212 insertions(+), 172 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index dde459a7815..1174f9af473 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -50,60 +50,49 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemProgram(EnergyManagementSystemProgram & modelObject) { boost::optional s; - //boost::smatch matches; - //bool result; - int found = 0; + const int subs[] = {1}; + std::string possible_uid; + size_t pos; + std::string newline; IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); m_idfObjects.push_back(idfObject); m_map.insert(std::make_pair(modelObject.handle(), idfObject)); - //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Program,modelObject); //Name s = modelObject.name(); if (s) { idfObject.setName(*s); } - for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { + const Model m = modelObject.model(); + const std::vector modelObjects = m.getModelObjects(); + + for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); OptionalString line = eg.getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); - if (line) { - //result = boost::regex_search(line.get(), matches, openstudio::uuidInString()); - //boost::sregex_token_iterator iter(line.get().begin(), line.get().end(), openstudio::uuidInString(),0); - - //split string on whitespaces to isolate possible uids - std::vector results = splitString(line.get(), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //possible uid so set found to 1 - found = 1; - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - Model m = modelObject.model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - results.at(j) = modelObjects.at(k).nameString(); - }; - } - }; - } - } - std::string final_line; - for (size_t z = 0; z < results.size(); z++) { - final_line += results.at(z) + ' '; - } - if (final_line.back() == ' ') { - boost::erase_last(final_line, " "); + if (line) { + //find uids + newline = line.get(); + boost::sregex_token_iterator j(line.get().begin(), line.get().end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + //replace uid with namestring + pos = newline.find(possible_uid); + if (pos+38 <= newline.length()) { + newline.replace(pos, 38, modelObjects.at(k).nameString()); + } + break; + }; + } + }; } - group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, final_line); - + group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, newline); } OptionalString comment = eg.fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); if (comment) { diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp index 79607b88e34..fd928ccc75b 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -50,59 +50,49 @@ namespace energyplus { boost::optional ForwardTranslator::translateEnergyManagementSystemSubroutine(EnergyManagementSystemSubroutine & modelObject) { boost::optional s; - int found = 0; + const int subs[] = {1}; + std::string possible_uid; + size_t pos; + std::string newline; IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine); m_idfObjects.push_back(idfObject); m_map.insert(std::make_pair(modelObject.handle(), idfObject)); - //IdfObject program = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine, modelObject); //Name s = modelObject.name(); if (s) { idfObject.setName(*s); } - + + const Model m = modelObject.model(); + const std::vector modelObjects = m.getModelObjects(); for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); OptionalString line = eg.getString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); if (line) { - //result = boost::regex_search(line.get(), matches, openstudio::uuidInString()); - //boost::sregex_token_iterator iter(line.get().begin(), line.get().end(), openstudio::uuidInString(),0); - - //split string on whitespaces to isolate possible uids - std::vector results = splitString(line.get(), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //possible uid so set found to 1 - found = 1; - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - Model m = modelObject.model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - results.at(j) = modelObjects.at(k).nameString(); - }; - } - }; - } - } - std::string final_line; - for (size_t z = 0; z < results.size(); z++) { - final_line += results.at(z) + ' '; + //find uids + newline = line.get(); + boost::sregex_token_iterator j(line.get().begin(), line.get().end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + //replace uid with namestring + pos = newline.find(possible_uid); + if (pos + 38 <= newline.length()) { + newline.replace(pos, 38, modelObjects.at(k).nameString()); + } + break; + }; + } + }; } - if (final_line.back() == ' ') { - boost::erase_last(final_line, " "); - } - group.setString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, final_line); - + group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, newline); } OptionalString comment = eg.fieldComment(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); if (comment) { diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index f17032660ba..4f44b7434e0 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -474,11 +474,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + "!- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; //this is what the body should look like with 2 /n's and compare TRUE - std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; //the added lines should compare TRUE to below - std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " / 15.0 !- This is !nonsense\n"; + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " !- This is !nonsense\n"; std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //set body diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index f907d0a2717..7ea8989ed4d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -298,32 +298,32 @@ namespace detail { std::vector EnergyManagementSystemProgram_Impl::referencedObjects() const { //return vector of model objects that are referenced in program std::vector result; + const int subs[] = {1}; + std::string possible_uid; + + const Model m = this->model(); + const std::vector modelObjects = m.getModelObjects(); boost::optional> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings for (size_t i = 0; i < body.get().size(); i++) { - //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get().at(i), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - //std::vector handle = &uid; - Model m = this->model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - result.push_back(modelObjects.at(k)); - }; - } - }; - } + //find uids + boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //TODO cant get below to work so try the manual way + //m.getModelObjects(&uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + result.push_back(modelObjects.at(k)); + }; + } + }; } } } @@ -333,37 +333,36 @@ namespace detail { std::vector EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { //return vector of body lines that contain missing uid strings for invalid referenced objects std::vector result; + const int subs[] = {1}; + std::string possible_uid; + + const Model m = this->model(); + const std::vector modelObjects = m.getModelObjects(); boost::optional> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings for (size_t i = 0; i < body.get().size(); i++) { int found = 0; - //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get().at(i), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //possible uid so set found to 1 - found = 1; - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - //std::vector handle = &uid; - Model m = this->model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - }; - } - }; - } + //find uids + boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + found = 1; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //TODO cant get below to work so try the manual way + //m.getModelObjects(&uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + found++; + }; + } + }; } - //possible uid not found in model + //possible uid NOT found in model if (found == 1) { result.push_back(body.get().at(i)); }; diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 6f7efba23f6..7d3b1e6c30d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -294,32 +294,32 @@ namespace detail { std::vector EnergyManagementSystemSubroutine_Impl::referencedObjects() const { //return vector of model objects that are referenced in program std::vector result; + const int subs[] = {1}; + std::string possible_uid; + + const Model m = this->model(); + const std::vector modelObjects = m.getModelObjects(); boost::optional> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings for (size_t i = 0; i < body.get().size(); i++) { - //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get().at(i), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - //std::vector handle = &uid; - Model m = this->model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - result.push_back(modelObjects.at(k)); - }; - } - }; - } + //find uids + boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //TODO cant get below to work so try the manual way + //m.getModelObjects(&uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + result.push_back(modelObjects.at(k)); + }; + } + }; } } } @@ -329,37 +329,36 @@ namespace detail { std::vector EnergyManagementSystemSubroutine_Impl::invalidReferencedObjects() const { //return vector of body lines that contain missing uid strings for invalid referenced objects std::vector result; + const int subs[] = {1}; + std::string possible_uid; + + const Model m = this->model(); + const std::vector modelObjects = m.getModelObjects(); boost::optional> body = this->lines(); if (body.is_initialized()) { //assume body is a vector of strings for (size_t i = 0; i < body.get().size(); i++) { int found = 0; - //split string on whitespaces to isolate possible uids - std::vector results = splitString(body.get().at(i), ' '); - for (size_t j = 0; j < results.size(); j++) { - if (results.at(j).size() == 38) { - //possible uid so set found to 1 - found = 1; - //remove {} from uid string - std::string possible_uid = results.at(j).substr(1, results.at(j).size() - 2); - //look to see if uid is in the model and return the object - UUID uid = toUUID(possible_uid); - //std::vector handle = &uid; - Model m = this->model(); - //TODO cant get below to work so try the harder way - //m.getModelObjects(&uid); - std::vector modelObjects = m.getModelObjects(); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - }; - } - }; - } + //find uids + boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + found = 1; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + //TODO cant get below to work so try the manual way + //m.getModelObjects(&uid); + if (modelObjects.size() > 0) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).handle() == uid) { + found++; + }; + } + }; } - //possible uid not found in model + //possible uid NOT found in model if (found == 1) { result.push_back(body.get().at(i)); }; diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 1cde2d14ca5..aaa1e674aa0 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -246,3 +246,66 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { model.save(toPath("./EMS_nametest.osm"), true); } +TEST_F(ModelFixture, EMSProgramUid_EMSProgramUid) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // add Site Outdoor Air Drybulb Temperature + OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); + + //add sensor + EnergyManagementSystemSensor OATdbSensor(model); + OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + + //add fan + Schedule s = model.alwaysOnDiscreteSchedule(); + FanConstantVolume fan(model, s); + fan.setName("fan"); + + //add actuator on fan + EnergyManagementSystemActuator fanActuator(fan); + std::string fanName = fan.name().get() + "Pressure_Actuator"; + fanActuator.setName(fanName); + std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); + std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); + + //add program + EnergyManagementSystemProgram fan_program_1(model); + std::string programName = fan.name().get() + "Pressure_Rise_Program_by_Body"; + fan_program_1.setName(programName); + //this body has /r/n in it + std::string fan_program_1_body = "SET mult = " + toString(fanActuator.handle()) + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense"; + //this is what the body should look like with 2 /n's and compare TRUE + std::string fan_program_body_test = "SET mult = " + toString(fanActuator.handle()) + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + //the added lines should compare TRUE to below + std::string line1_test = "SET mult = " + toString(fanActuator.handle()) + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\n"; + std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; + + //set body + fan_program_1.setBody(fan_program_1_body); + + //check body + boost::optional body = fan_program_1.body(); + EXPECT_EQ(fan_program_body_test, body.get()); + + //check lines + boost::optional> lines = fan_program_1.lines(); + EXPECT_EQ(2, lines.get().size()); + EXPECT_EQ(line1_test, lines.get()[0]); + EXPECT_EQ(line2_test, lines.get()[1]); + + model.save(toPath("./EMS_programUID.osm"), true); + + EXPECT_EQ(3, fan_program_1.referencedObjects().size()); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[0].nameString() == fanName) || (fan_program_1.referencedObjects()[0].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[1].nameString() == fanName) || (fan_program_1.referencedObjects()[1].nameString() == "OATdb_Sensor")); + EXPECT_EQ(true, (fan_program_1.referencedObjects()[2].nameString() == fanName) || (fan_program_1.referencedObjects()[2].nameString() == "OATdb_Sensor")); +} + From 35a865c0ed7a7c097ee555588e66630c76892064 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sat, 24 Sep 2016 10:17:50 -0600 Subject: [PATCH 127/159] test update --- openstudiocore/src/energyplus/Test/EMS_GTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 4f44b7434e0..33f6d8fe99e 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -453,7 +453,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { //add sensor EnergyManagementSystemSensor OATdbSensor(model); - OATdbSensor.setName("OATdb Sensor"); + OATdbSensor.setName("OATdb Sensor really really really really really long name"); OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan @@ -463,7 +463,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { //add actuator on fan EnergyManagementSystemActuator fanActuator(fan); std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName); + fanActuator.setName(fanName + "really really really really really long name"); std::string fanControlType = "Fan Pressure Rise"; fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; @@ -474,11 +474,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + "!- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; + std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " extra!- This is !nonsense\r\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment"; //this is what the body should look like with 2 /n's and compare TRUE - std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; + std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " extra !- This is !nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n" + "no comment\n" + "crap !comment!comment\n"; //the added lines should compare TRUE to below - std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " !- This is !nonsense\n"; + std::string line1_test = "SET mult = " + toString(OATdbSensor.handle()) + " + " + toString(fanActuator.handle()) + " extra !- This is !nonsense\n"; std::string line2_test = "SET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //set body From e37e09cd8e3f3695fd6c95ef7faaabf2659e34ab Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sun, 25 Sep 2016 10:27:24 -0600 Subject: [PATCH 128/159] enforce ReverseTranslation order for certain EMS objects --- ...ateEnergyManagementSystemMeteredOutputVariable.cpp | 11 +++++++++++ ...eTranslateEnergyManagementSystemOutputVariable.cpp | 11 +++++++++++ .../ReverseTranslateEnergyManagementSystemProgram.cpp | 11 +++++++++++ ...ateEnergyManagementSystemProgramCallingManager.cpp | 8 ++++++++ ...verseTranslateEnergyManagementSystemSubroutine.cpp | 11 +++++++++++ 5 files changed, 52 insertions(+) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 937e6875217..47cba3ebc83 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -45,6 +45,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut return boost::none; } + //make sure all other objects are translated first except below + for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { + if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable)) { + translateAndMapWorkspaceObject(workspaceObject); + } + } + OptionalString s = workspaceObject.getString(EnergyManagementSystem_MeteredOutputVariableFields::Name); if(!s){ LOG(Error, "WorkspaceObject EnergyManagementSystem_MeteredOutputVariable has no Name"); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp index 8f202e8d0c9..433248a4576 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -45,6 +45,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari return boost::none; } + //make sure all other objects are translated first except below + for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { + if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable)) { + translateAndMapWorkspaceObject(workspaceObject); + } + } + OptionalString s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Name); if (!s) { LOG(Error, "EnergyManagementSystem_OutputVariable has no Name"); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp index f699a40c99e..0521c262822 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp @@ -48,6 +48,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgram(co return boost::none; } + //make sure all other objects are translated first + for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { + if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable)) { + translateAndMapWorkspaceObject(workspaceObject); + } + } + openstudio::model::EnergyManagementSystemProgram emsProgram(m_model); emsProgram.setName(*s); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp index d589156d7e9..ffab053e451 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgramCallingManager.cpp @@ -50,6 +50,14 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgramCal return boost::none; } + //make sure all other objects are translated first except below + for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { + if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager)) { + translateAndMapWorkspaceObject(workspaceObject); + } + } + openstudio::model::EnergyManagementSystemProgramCallingManager emsProgramCallingManager(m_model); emsProgramCallingManager.setName(*s); diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp index 704a71cafdb..67518f40d76 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp @@ -48,6 +48,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSubroutine return boost::none; } + //make sure all other objects are translated first except below + for (const WorkspaceObject& workspaceObject : m_workspace.objects()) { + if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable) + && (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable)) { + translateAndMapWorkspaceObject(workspaceObject); + } + } + openstudio::model::EnergyManagementSystemSubroutine emsProgram(m_model); emsProgram.setName(*s); From 958ab074a177b453bbdb4c05fea74cc1f0567232 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Sun, 25 Sep 2016 11:17:12 -0600 Subject: [PATCH 129/159] swap names for UIDs in RT for program/subroutine --- ...TranslateEnergyManagementSystemProgram.cpp | 25 ++++++++++++++++++- ...nslateEnergyManagementSystemSubroutine.cpp | 25 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp index 0521c262822..ced30a78bf1 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemProgram.cpp @@ -24,6 +24,7 @@ #include "../../utilities/idf/IdfExtensibleGroup.hpp" #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" +#include "../../utilities/core/StringHelpers.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -62,12 +63,34 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemProgram(co openstudio::model::EnergyManagementSystemProgram emsProgram(m_model); emsProgram.setName(*s); + //get all model objects so we can do name / uid substitution + const std::vector modelObjects = m_model.getModelObjects(); + size_t pos, len; + std::string newline, uid; + unsigned n = workspaceObject.numExtensibleGroups(); OptionalString line; for (unsigned i = 0; i < n; ++i) { line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine); if (line) { - emsProgram.addLine(line.get()); + newline = line.get(); + //split line on whitespaces to get look for modelobject names + std::vector results = splitString(line.get(), ' '); + for (size_t j = 0; j < results.size(); j++) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).name()) { + //check if program item is the name of a model object + if (modelObjects.at(k).name().get() == results.at(j)) { + pos = newline.find(results.at(j)); + len = results.at(j).length(); + uid = toString(modelObjects.at(k).handle()); + //replace modelobject name with handle + newline.replace(pos, len, uid); + } + } + } + } + emsProgram.addLine(newline); } } return emsProgram; diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp index 67518f40d76..db89fd73e42 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSubroutine.cpp @@ -24,6 +24,7 @@ #include "../../utilities/idf/IdfExtensibleGroup.hpp" #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp" +#include "../../utilities/core/StringHelpers.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -62,12 +63,34 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSubroutine openstudio::model::EnergyManagementSystemSubroutine emsProgram(m_model); emsProgram.setName(*s); + //get all model objects so we can do name / uid substitution + const std::vector modelObjects = m_model.getModelObjects(); + size_t pos, len; + std::string newline, uid; + unsigned n = workspaceObject.numExtensibleGroups(); OptionalString line; for (unsigned i = 0; i < n; ++i) { line = workspaceObject.getExtensibleGroup(i).cast().getString(EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine); if (line) { - emsProgram.addLine(line.get()); + newline = line.get(); + //split line on whitespaces to get look for modelobject names + std::vector results = splitString(line.get(), ' '); + for (size_t j = 0; j < results.size(); j++) { + for (size_t k = 0; k < modelObjects.size(); k++) { + if (modelObjects.at(k).name()) { + //check if program item is the name of a model object + if (modelObjects.at(k).name().get() == results.at(j)) { + pos = newline.find(results.at(j)); + len = results.at(j).length(); + uid = toString(modelObjects.at(k).handle()); + //replace modelobject name with handle + newline.replace(pos, len, uid); + } + } + } + } + emsProgram.addLine(newline); } } return emsProgram; From ef34d3e80689fa2eb2e2d894dc1bd58f6e400df2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 26 Sep 2016 14:06:03 -0600 Subject: [PATCH 130/159] add constructors for all the required fields --- ...teEnergyManagementSystemGlobalVariable.cpp | 2 +- .../src/energyplus/Test/EMS_GTest.cpp | 12 +++++----- .../model/EnergyManagementSystemActuator.cpp | 23 +++++++++++++++++++ .../model/EnergyManagementSystemActuator.hpp | 2 ++ .../EnergyManagementSystemGlobalVariable.cpp | 2 +- .../EnergyManagementSystemGlobalVariable.hpp | 2 +- ...EnergyManagementSystemInternalVariable.cpp | 10 ++++++++ ...EnergyManagementSystemInternalVariable.hpp | 1 + ...yManagementSystemMeteredOutputVariable.cpp | 14 +++++++++++ ...yManagementSystemMeteredOutputVariable.hpp | 2 ++ .../EnergyManagementSystemOutputVariable.cpp | 11 +++++++++ .../EnergyManagementSystemOutputVariable.hpp | 1 + .../EnergyManagementSystemTrendVariable.cpp | 11 +++++++++ .../EnergyManagementSystemTrendVariable.hpp | 1 + ...gyManagementSystemGlobalVariable_GTest.cpp | 2 +- ...gyManagementSystemOutputVariable_GTest.cpp | 2 +- ...rgyManagementSystemTrendVariable_GTest.cpp | 2 +- 17 files changed, 88 insertions(+), 12 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp index a5d84771ae1..08b21794630 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemGlobalVariable.cpp @@ -49,7 +49,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemGlobalVari for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { boost::optional value = eg.getString(EnergyManagementSystem_GlobalVariableExtensibleFields::ErlVariableName); if (value) { - openstudio::model::EnergyManagementSystemGlobalVariable emsGlobalVariable(value.get(), m_model); + openstudio::model::EnergyManagementSystemGlobalVariable emsGlobalVariable(m_model, value.get()); if (!result) { result = emsGlobalVariable; } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 33f6d8fe99e..2e636543ffc 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -738,11 +738,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorGlobalVariable_EMS) { Model model; // add global variable - EnergyManagementSystemGlobalVariable var("glob var", model); + EnergyManagementSystemGlobalVariable var(model, "glob var"); EXPECT_EQ("glob_var", var.nameString()); // add global variable - EnergyManagementSystemGlobalVariable var2("glob var 2", model); + EnergyManagementSystemGlobalVariable var2(model, "glob var 2"); EXPECT_EQ("glob_var_2", var2.nameString()); ForwardTranslator forwardTranslator; @@ -774,11 +774,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { Model model; // add global variable - EnergyManagementSystemGlobalVariable var("glob var", model); + EnergyManagementSystemGlobalVariable var(model,"glob var"); EXPECT_EQ("glob_var", var.nameString()); // add global variable - EnergyManagementSystemGlobalVariable var2("glob var 2", model); + EnergyManagementSystemGlobalVariable var2(model, "glob var 2"); EXPECT_EQ("glob_var_2", var2.nameString()); // add output variable @@ -826,7 +826,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { Model model; // add global variable - EnergyManagementSystemGlobalVariable globvar("glob var", model); + EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable EnergyManagementSystemTrendVariable var(model); @@ -1047,7 +1047,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { Model model; // add global variable - EnergyManagementSystemGlobalVariable globvar("glob var", model); + EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable EnergyManagementSystemTrendVariable var(model); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 9a2ee90fd7e..9f80fce523c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -106,6 +106,29 @@ namespace detail { } // detail +EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject, std::string actuatedComponentType, std::string actuatedComponentControlType) + : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { + OS_ASSERT(getImpl()); + bool ok = setActuatedComponent(modelObject); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s setActuatedComponent to " + << modelObject.briefDescription() << "."); + } + ok = setActuatedComponentType(actuatedComponentType); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s actuatedComponentType to " + << actuatedComponentType << "."); + } + ok = setActuatedComponentControlType(actuatedComponentControlType); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s actuatedComponentControlType to " + << actuatedComponentControlType << "."); + } +} + EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject) : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index b58d959bdc6..0fbbd8da1da 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -38,6 +38,8 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemActuator(const ModelObject& modelObject, std::string actuatedComponentType, std::string actuatedComponentControlType); + explicit EnergyManagementSystemActuator(const ModelObject& modelObject); explicit EnergyManagementSystemActuator(const Model& model); diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp index 74f3b8cf717..8a4387ebce0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.cpp @@ -68,7 +68,7 @@ namespace detail { } // detail -EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const std::string& variableName, const Model& model) +EnergyManagementSystemGlobalVariable::EnergyManagementSystemGlobalVariable(const Model& model, const std::string& variableName) : ModelObject(EnergyManagementSystemGlobalVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); diff --git a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp index b59ba9ba95e..6f57d68a856 100644 --- a/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemGlobalVariable.hpp @@ -38,7 +38,7 @@ class MODEL_API EnergyManagementSystemGlobalVariable : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemGlobalVariable(const std::string& variableName, const Model& model); + explicit EnergyManagementSystemGlobalVariable(const Model& model, const std::string& variableName); virtual ~EnergyManagementSystemGlobalVariable() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp index 73a4738bc04..6b5393c71bc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -90,6 +90,16 @@ namespace detail { } // detail +EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(const Model& model, std::string internalDataType) +: ModelObject(EnergyManagementSystemInternalVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setInternalDataType(internalDataType); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s internalDataType to " << internalDataType << "."); + } +} + EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(const Model& model) : ModelObject(EnergyManagementSystemInternalVariable::iddObjectType(),model) { diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp index d3a9ba32e39..65e100d30a5 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -37,6 +37,7 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemInternalVariable(const Model& model, std::string internalDataType); explicit EnergyManagementSystemInternalVariable(const Model& model); diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 70ba2f99a04..74cf36e369c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -168,6 +168,20 @@ namespace detail { } // detail +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(eMSVariableName); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << eMSVariableName << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(),model) { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index fced7e5231f..ecafc56bb36 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -40,6 +40,8 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model); virtual ~EnergyManagementSystemMeteredOutputVariable() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 2b23e854a27..667a724f6cc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -134,6 +134,17 @@ namespace detail { } // detail +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName) +: ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(eMSVariableName); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << eMSVariableName << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index d2f561df640..4a7ebf2b169 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -39,6 +39,7 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName); explicit EnergyManagementSystemOutputVariable(const Model& model); diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index 0eb84ef9575..2d44e78839d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -86,6 +86,17 @@ namespace detail { } // detail +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(eMSVariableName); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << eMSVariableName << "."); + } + setNumberofTimestepstobeLogged(1); +} + EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp index 828fa80b739..ea2320af09d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -37,6 +37,7 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ + explicit EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName); explicit EnergyManagementSystemTrendVariable(const Model& model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp index 6fee9bb70f8..611751577f4 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemGlobalVariable_GTest.cpp @@ -39,7 +39,7 @@ TEST_F(ModelFixture, EMSGlobalVariable_EMSGlobalVariable) Model model; // add global variable - EnergyManagementSystemGlobalVariable var("glob var", model); + EnergyManagementSystemGlobalVariable var(model, "glob var"); EXPECT_EQ("glob_var", var.nameString()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 74b4a7a9a94..92b69484e1c 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -59,7 +59,7 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) ThermalZone zone2(model); // add global variable - EnergyManagementSystemGlobalVariable var("globalVar", model); + EnergyManagementSystemGlobalVariable var(model, "globalVar"); // add Site Outdoor Air Drybulb Temperature OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index 0ac81c93610..72f9ba9f8d2 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -40,7 +40,7 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) Model model; // add global variable - EnergyManagementSystemGlobalVariable globvar("glob var", model); + EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable EnergyManagementSystemTrendVariable var(model); From ef021848813e7c85419c27e5f20dbf1f6a79013b Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 27 Sep 2016 13:55:43 -0600 Subject: [PATCH 131/159] change sensor IDD from \object-list to \alpha bc of outputmeter auto naming issues --- openstudiocore/resources/model/OpenStudio.idd | 12 +--- .../model/EnergyManagementSystemProgram.cpp | 2 +- .../model/EnergyManagementSystemSensor.cpp | 61 +++++++++++++++++-- .../model/EnergyManagementSystemSensor.hpp | 4 ++ .../EnergyManagementSystemSensor_Impl.hpp | 3 + openstudiocore/src/model/OutputMeter.cpp | 22 +++++++ openstudiocore/src/model/OutputMeter.hpp | 2 + openstudiocore/src/model/OutputMeter_Impl.hpp | 2 + openstudiocore/src/model/OutputVariable.cpp | 25 ++++++++ openstudiocore/src/model/OutputVariable.hpp | 2 + .../src/model/OutputVariable_Impl.hpp | 2 + 11 files changed, 123 insertions(+), 14 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 63555f179f9..3fc5e6afd27 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26249,9 +26249,9 @@ OS:Output:Meter, A2, \field Name \note Form is EnergyUseType:..., e.g. Electricity:* for all Electricity meters \note or EndUse:..., e.g. GeneralLights:* for all General Lights + \type external-list \required-field - \reference OutputMeterNames - \reference OutputVariableMeterNames + \external-list autoRDDmeter A3, \field Reporting Frequency \note Timestep refers to the zone Timestep/Number of Timesteps in hour value \note RunPeriod, Environment, and Annual are the same @@ -26290,7 +26290,6 @@ OS:Output:Variable, \type alpha \required-field \reference OutputVariableNames - \reference OutputVariableMeterNames A3, \field Key Value \note use '*' (without quotes) to apply this variable to all keys \type alpha @@ -26328,8 +26327,6 @@ OS:Meter:Custom, \required-field A2, \field Name \required-field - \reference OutputMeterNames - \reference OutputVariableMeterNames A3, \field Fuel Type \type choice \key Electricity @@ -26358,8 +26355,6 @@ OS:Meter:CustomDecrement, \required-field A2, \field Name \required-field - \reference OutputMeterNames - \reference OutputVariableMeterNames A3, \field Fuel Type \type choice \key Electricity @@ -26431,8 +26426,7 @@ OS:EnergyManagementSystem:Sensor, \note key name listed here will override key name in Output:Variable or Output:Meter A4; \field Output Variable or Output Meter Name \required-field - \type object-list - \object-list OutputVariableMeterNames + \type alpha OS:EnergyManagementSystem:Actuator, \memo Hardware portion of EMS used to set up actuators in the model diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 7ea8989ed4d..987ce13cce4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -316,7 +316,7 @@ namespace detail { //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); //TODO cant get below to work so try the manual way - //m.getModelObjects(&uid); + //m.getModelObject(uid); if (modelObjects.size() > 0) { for (size_t k = 0; k < modelObjects.size(); k++) { if (modelObjects.at(k).handle() == uid) { diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index fa43f13cade..6a09461c569 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -25,10 +25,13 @@ #include "OutputMeter.hpp" #include "OutputMeter_Impl.hpp" +#include "Model.hpp" + #include #include #include "../utilities/core/Assert.hpp" +#include "../utilities/core/UUID.hpp" namespace openstudio { namespace model { @@ -97,21 +100,63 @@ namespace detail { } bool EnergyManagementSystemSensor_Impl::setOutputVariable(const OutputVariable& outputVariable) { - bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); + //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, toString(outputVariable.handle())); + return result; + } + + bool EnergyManagementSystemSensor_Impl::resetOutputMeter() { + //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, ""); + return result; + } + + bool EnergyManagementSystemSensor_Impl::resetOutputVariable() { + //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, ""); return result; } bool EnergyManagementSystemSensor_Impl::setOutputMeter(const OutputMeter& outputMeter) { - bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); + //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, toString(outputMeter.handle())); return result; } boost::optional EnergyManagementSystemSensor_Impl::optionalOutputVariable() const { - return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + //Note: Cant do /object-list implementation since Auto Naming of Objects causes issues. + // Instead, doing an /alpha getString implementation + //return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + boost::optional handle = getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + const Model m = this->model(); + if (handle) { + UUID uid = toUUID(handle.get()); + boost::optional object = m.getModelObject(uid); + if (object) { + if (object->optionalCast()) { + return object->cast(); + } + } + } + return boost::none; } boost::optional EnergyManagementSystemSensor_Impl::optionalOutputMeter() const { - return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + //Note: Cant do /object-list implementation since Auto Naming of Objects causes issues. + // Instead, doing an /alpha getString implementation + //return getObject().getModelObjectTarget(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + boost::optional handle = getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName); + const Model m = this->model(); + if (handle) { + UUID uid = toUUID(handle.get()); + boost::optional object = m.getModelObject(uid); + if (object) { + if (object->optionalCast()) { + return object->cast(); + } + } + } + return boost::none; } } // detail @@ -173,6 +218,14 @@ bool EnergyManagementSystemSensor::setOutputMeter(const OutputMeter& outputMeter return getImpl()->setOutputMeter(outputMeter); } +bool EnergyManagementSystemSensor::resetOutputVariable() { + return getImpl()->resetOutputVariable(); +} + +bool EnergyManagementSystemSensor::resetOutputMeter() { + return getImpl()->resetOutputMeter(); +} + /// @cond EnergyManagementSystemSensor::EnergyManagementSystemSensor(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index 5a8a05e291c..3203226ac3a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -73,6 +73,10 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); + + bool resetOutputVariable(); + bool resetOutputMeter(); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index d2352d20f71..03da0a112c8 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -81,6 +81,9 @@ namespace detail { bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); + bool resetOutputVariable(); + bool resetOutputMeter(); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/OutputMeter.cpp b/openstudiocore/src/model/OutputMeter.cpp index a56a279c0e2..94a6cd85496 100644 --- a/openstudiocore/src/model/OutputMeter.cpp +++ b/openstudiocore/src/model/OutputMeter.cpp @@ -25,6 +25,8 @@ #include "Facility_Impl.hpp" #include "Building.hpp" #include "Building_Impl.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" #include @@ -97,6 +99,22 @@ namespace detail { return result; } + std::vector OutputMeter_Impl::remove() { + //Note: Cant do /object-list implementation for EMS Sensor since Auto Naming of Objects causes issues. + // Instead, doing an /alpha getString implementation so we need to manually remove any referring Sensors + const Model m = this->model(); + + std::vector objects = m.getModelObjects(); + for (auto & sensor : objects) { + if (sensor.outputMeter()) { + if (sensor.outputMeter().get().name() == this->name()) { + sensor.resetOutputMeter(); + } + } + } + return ModelObject_Impl::remove(); + } + std::string OutputMeter_Impl::name() const { boost::optional value = getString(OS_Output_MeterFields::Name,true); OS_ASSERT(value); @@ -625,6 +643,10 @@ openstudio::OptionalTimeSeries OutputMeter::getData(const std::string& envPeriod return getImpl()->getData(envPeriod, specificInstallLocation); } +std::vector OutputMeter::remove() { + return getImpl()->remove(); +} + bool MeterFuelTypeEquals(const OutputMeter& meter,const FuelType& ft) { OptionalFuelType oft = meter.fuelType(); if (oft && (oft.get() == ft)) { return true; } diff --git a/openstudiocore/src/model/OutputMeter.hpp b/openstudiocore/src/model/OutputMeter.hpp index 0b7cc1c063a..3062943df20 100644 --- a/openstudiocore/src/model/OutputMeter.hpp +++ b/openstudiocore/src/model/OutputMeter.hpp @@ -57,6 +57,8 @@ class MODEL_API OutputMeter : public ModelObject { virtual ~OutputMeter() {} + virtual std::vector remove(); + //@} /** @name Static Methods */ //@{ diff --git a/openstudiocore/src/model/OutputMeter_Impl.hpp b/openstudiocore/src/model/OutputMeter_Impl.hpp index 589eb002c0a..a72d74c0019 100644 --- a/openstudiocore/src/model/OutputMeter_Impl.hpp +++ b/openstudiocore/src/model/OutputMeter_Impl.hpp @@ -73,6 +73,8 @@ namespace detail { virtual IddObjectType iddObjectType() const override; + virtual std::vector remove() override; + /** @name Getters */ //@{ diff --git a/openstudiocore/src/model/OutputVariable.cpp b/openstudiocore/src/model/OutputVariable.cpp index cd237571ab8..aab123c2dcb 100644 --- a/openstudiocore/src/model/OutputVariable.cpp +++ b/openstudiocore/src/model/OutputVariable.cpp @@ -21,6 +21,10 @@ #include "OutputVariable_Impl.hpp" #include "Schedule.hpp" #include "Schedule_Impl.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" + +#include "Model.hpp" #include @@ -80,6 +84,23 @@ namespace detail { return OutputVariable::iddObjectType(); } + std::vector OutputVariable_Impl::remove() { + //Note: Cant do /object-list implementation for EMS Sensor since Auto Naming of Objects causes issues. + // Instead, doing an /alpha getString implementation so we need to manually remove any referring Sensors + const Model m = this->model(); + + std::vector objects = m.getModelObjects(); + for (auto & sensor : objects) { + if (sensor.outputVariable()) { + if (sensor.outputVariable().get().variableName() == this->name()) { + sensor.resetOutputVariable(); + } + } + } + + return ModelObject_Impl::remove(); + } + std::vector OutputVariable_Impl::getScheduleTypeKeys(const Schedule& schedule) const { std::vector result; @@ -296,5 +317,9 @@ void OutputVariable::resetSchedule() getImpl()->resetSchedule(); } +std::vector OutputVariable::remove() { + return getImpl()->remove(); +} + } // model } // openstudio diff --git a/openstudiocore/src/model/OutputVariable.hpp b/openstudiocore/src/model/OutputVariable.hpp index 7ef258bf554..567162113fb 100644 --- a/openstudiocore/src/model/OutputVariable.hpp +++ b/openstudiocore/src/model/OutputVariable.hpp @@ -56,6 +56,8 @@ class MODEL_API OutputVariable : public ModelObject { /// Constructs a new OutputVariable object in the model. explicit OutputVariable(const std::string& variableName, const Model& model); + virtual std::vector remove(); + //@} static IddObjectType iddObjectType(); diff --git a/openstudiocore/src/model/OutputVariable_Impl.hpp b/openstudiocore/src/model/OutputVariable_Impl.hpp index 6d4f519d3ba..e9db1e54838 100644 --- a/openstudiocore/src/model/OutputVariable_Impl.hpp +++ b/openstudiocore/src/model/OutputVariable_Impl.hpp @@ -74,6 +74,8 @@ namespace detail { virtual std::vector getScheduleTypeKeys(const Schedule& schedule) const override; + virtual std::vector remove() override; + //@} /** @name Getters */ //@{ From 0ee7e83a4657c5d823a6b17dff6c8032d38a3366 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 27 Sep 2016 14:47:49 -0600 Subject: [PATCH 132/159] fixing naming issues --- .../src/utilities/idf/IdfObject.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index eb6cffffa5b..361aac24a01 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -474,7 +474,30 @@ namespace detail { m_fields.push_back(newName); m_diffs.push_back(IdfObjectDiff(i, boost::none, newName)); } - return newName; // success! + switch (m_iddObject.type().value()) { + // get all EMS idd object types in both E+ and OS IDD + case openstudio::IddObjectType::EnergyManagementSystem_Actuator:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped + case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped + case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_InternalVariable:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Program:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Program:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Sensor:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_Subroutine:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_Subroutine:; // deliberate fall through + case openstudio::IddObjectType::EnergyManagementSystem_TrendVariable:; // deliberate fall through + case openstudio::IddObjectType::OS_EnergyManagementSystem_TrendVariable:; // deliberate fall through + return newName; // success! + default: + return _newName; // success! + } } return boost::none; // no name } From 6624183a2cf32a08b19987ced3a88e57419d4489 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 27 Sep 2016 18:10:27 -0600 Subject: [PATCH 133/159] Name Fix --- .../EnergyManagementSystemProgram_GTest.cpp | 14 ++++++++++ .../src/utilities/idf/IdfObject.cpp | 27 +++---------------- .../utilities/idf/Test/Workspace_GTest.cpp | 14 +++++++++- .../src/utilities/idf/Workspace.cpp | 4 +++ 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index aaa1e674aa0..9a4566ce261 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -243,6 +243,20 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram2) { EnergyManagementSystemProgram program_6(model); program_6.setName("name one_1"); EXPECT_EQ("name_one_2", program_6.nameString()); + EnergyManagementSystemProgram program_7(model); + program_7.setName("name one_1"); + EXPECT_EQ("name_one_3", program_7.nameString()); + + EnergyManagementSystemProgram program_8(model); + program_8.setName(" My (!@#$^&*()least)(*&^$#@!) favorite zone "); + EXPECT_EQ("____________My_(!@#$^&*()least)(*&^$#@!)_favorite_zone____________", program_8.nameString()); + EnergyManagementSystemProgram program_9(model); + program_9.setName(" My (!@#$^&*()least)(*&^$#@!) favorite zone "); + EXPECT_EQ("____________My_(!@#$^&*()least)(*&^$#@!)_favorite_zone_____________1", program_9.nameString()); + EnergyManagementSystemProgram program_10(model); + program_10.setName(" My (!@#$^&*()least)(*&^$#@!) favorite zone 1"); + EXPECT_EQ("____________My_(!@#$^&*()least)(*&^$#@!)_favorite_zone_____________2", program_10.nameString()); + model.save(toPath("./EMS_nametest.osm"), true); } diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index 361aac24a01..79b16e7f5e3 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -474,30 +474,9 @@ namespace detail { m_fields.push_back(newName); m_diffs.push_back(IdfObjectDiff(i, boost::none, newName)); } - switch (m_iddObject.type().value()) { - // get all EMS idd object types in both E+ and OS IDD - case openstudio::IddObjectType::EnergyManagementSystem_Actuator:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_Actuator:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_ConstructionIndexVariable:; // TODO uncomment when wrapped - case openstudio::IddObjectType::OS_EnergyManagementSystem_ConstructionIndexVariable:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_CurveOrTableIndexVariable:; // TODO uncomment when wrapped - case openstudio::IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_GlobalVariable:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_InternalVariable:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_InternalVariable:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_Program:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_Program:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_Sensor:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_Sensor:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_Subroutine:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_Subroutine:; // deliberate fall through - case openstudio::IddObjectType::EnergyManagementSystem_TrendVariable:; // deliberate fall through - case openstudio::IddObjectType::OS_EnergyManagementSystem_TrendVariable:; // deliberate fall through - return newName; // success! - default: - return _newName; // success! - } + //return decoded string since we might have made changes to it if its an EMS object. + newName = decodeString(newName); + return newName; // success! } return boost::none; // no name } diff --git a/openstudiocore/src/utilities/idf/Test/Workspace_GTest.cpp b/openstudiocore/src/utilities/idf/Test/Workspace_GTest.cpp index 388626180ff..7f99f64423c 100644 --- a/openstudiocore/src/utilities/idf/Test/Workspace_GTest.cpp +++ b/openstudiocore/src/utilities/idf/Test/Workspace_GTest.cpp @@ -1169,6 +1169,12 @@ TEST_F(IdfFixture,Workspace_ComplexNames) { EXPECT_TRUE(zone.setName("My (!@#$^&*()least)(*&^$#@!) favorite zone")); EXPECT_EQ("My (!@#$^&*()least)(*&^$#@!) favorite zone 1",zone.name().get()); + oObject = ws.addObject(IdfObject(IddObjectType::Zone)); + ASSERT_TRUE(oObject); + zone = *oObject; + EXPECT_TRUE(zone.setName("My (!@#$^&*()least)(*&^$#@!) favorite zone 1")); + EXPECT_EQ("My (!@#$^&*()least)(*&^$#@!) favorite zone 2", zone.name().get()); + oObject = ws.addObject(IdfObject(IddObjectType::Zone)); ASSERT_TRUE(oObject); zone = *oObject; @@ -1181,6 +1187,12 @@ TEST_F(IdfFixture,Workspace_ComplexNames) { EXPECT_TRUE(zone.setName("My (!@#$^&*()least)(*&^$#@!) favorite zone ")); EXPECT_EQ("My (!@#$^&*()least)(*&^$#@!) favorite zone 1",zone.name().get()); + oObject = ws.addObject(IdfObject(IddObjectType::Zone)); + ASSERT_TRUE(oObject); + zone = *oObject; + EXPECT_TRUE(zone.setName("My (!@#$^&*()least)(*&^$#@!) favorite zone 1")); + EXPECT_EQ("My (!@#$^&*()least)(*&^$#@!) favorite zone 2", zone.name().get()); + oObject = ws.addObject(IdfObject(IddObjectType::Zone)); ASSERT_TRUE(oObject); zone = *oObject; @@ -1229,7 +1241,7 @@ TEST_F(IdfFixture,Workspace_ComplexNames) { EXPECT_TRUE(zone.setName("My (!@#$^&*()least)(*&^$#@!) favorite zone ")); EXPECT_EQ("My (!@#$^&*()least)(*&^$#@!) favorite zone 1",zone.name().get()); - EXPECT_EQ(static_cast(15),ws.numObjectsOfType(IddObjectType::Zone)); + EXPECT_EQ(static_cast(17),ws.numObjectsOfType(IddObjectType::Zone)); } TEST_F(IdfFixture, Workspace_SpecialNames) { diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index f9b36b7233e..39edd6e59a1 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1984,6 +1984,10 @@ namespace detail { ++count; } if (suffix > 0 && count == strSuffix.size() ) { + //debugging end name space issues + //std::string temp = objectName.substr(0, found); + //int size_temp = temp.size(); + //int size = objectName.size(); return objectName.substr(0, found); } } From 1d92e338c264c5af0734a4dc4c121be9a086ef2a Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 28 Sep 2016 11:38:56 -0600 Subject: [PATCH 134/159] code efficiency and cleanup --- ...TranslateEnergyManagementSystemProgram.cpp | 20 +++++-------- ...yManagementSystemProgramCallingManager.cpp | 2 -- ...nslateEnergyManagementSystemSubroutine.cpp | 20 +++++-------- .../model/EnergyManagementSystemProgram.cpp | 30 +++++++------------ .../EnergyManagementSystemSubroutine.cpp | 30 +++++++------------ .../EnergyManagementSystemSensor_GTest.cpp | 12 ++++++++ 6 files changed, 48 insertions(+), 66 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index 1174f9af473..a84201372b5 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -65,7 +65,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro } const Model m = modelObject.model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional mObject; for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); @@ -79,18 +79,14 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro possible_uid = *j++; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - //replace uid with namestring - pos = newline.find(possible_uid); - if (pos+38 <= newline.length()) { - newline.replace(pos, 38, modelObjects.at(k).nameString()); - } - break; - }; + mObject = m.getModelObject(uid); + if (mObject) { + //replace uid with namestring + pos = newline.find(possible_uid); + if (pos + 38 <= newline.length()) { + newline.replace(pos, 38, mObject.get().nameString()); } - }; + } } group.setString(EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, newline); } diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp index 35663ce5192..348d2fb271e 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgramCallingManager.cpp @@ -50,8 +50,6 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro { boost::optional s; - //IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); - //m_idfObjects.push_back(idfObject); IdfObject pcm = createAndRegisterIdfObject(openstudio::IddObjectType::EnergyManagementSystem_ProgramCallingManager, modelObject); //Name s = modelObject.name(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp index fd928ccc75b..5d5d7731590 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -65,7 +65,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSub } const Model m = modelObject.model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional mObject; for (const IdfExtensibleGroup& eg : modelObject.extensibleGroups()) { IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); @@ -79,18 +79,14 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSub possible_uid = *j++; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - //replace uid with namestring - pos = newline.find(possible_uid); - if (pos + 38 <= newline.length()) { - newline.replace(pos, 38, modelObjects.at(k).nameString()); - } - break; - }; + mObject = m.getModelObject(uid); + if (mObject) { + //replace uid with namestring + pos = newline.find(possible_uid); + if (pos + 38 <= newline.length()) { + newline.replace(pos, 38, mObject.get().nameString()); } - }; + } } group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, newline); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 987ce13cce4..7bfd2213267 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -302,7 +302,7 @@ namespace detail { std::string possible_uid; const Model m = this->model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional modelObject; boost::optional> body = this->lines(); if (body.is_initialized()) { @@ -315,15 +315,10 @@ namespace detail { possible_uid = *j++; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - //TODO cant get below to work so try the manual way - //m.getModelObject(uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - result.push_back(modelObjects.at(k)); - }; - } - }; + modelObject = m.getModelObject(uid); + if (modelObject) { + result.push_back(modelObject.get()); + } } } } @@ -337,7 +332,7 @@ namespace detail { std::string possible_uid; const Model m = this->model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional modelObject; boost::optional> body = this->lines(); if (body.is_initialized()) { @@ -352,15 +347,10 @@ namespace detail { found = 1; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - //TODO cant get below to work so try the manual way - //m.getModelObjects(&uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - }; - } - }; + modelObject = m.getModelObject(uid); + if (modelObject) { + found++; + } } //possible uid NOT found in model if (found == 1) { diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 7d3b1e6c30d..570bc4f9b22 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -298,7 +298,7 @@ namespace detail { std::string possible_uid; const Model m = this->model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional modelObject; boost::optional> body = this->lines(); if (body.is_initialized()) { @@ -311,15 +311,10 @@ namespace detail { possible_uid = *j++; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - //TODO cant get below to work so try the manual way - //m.getModelObjects(&uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - result.push_back(modelObjects.at(k)); - }; - } - }; + modelObject = m.getModelObject(uid); + if (modelObject) { + result.push_back(modelObject.get()); + } } } } @@ -333,7 +328,7 @@ namespace detail { std::string possible_uid; const Model m = this->model(); - const std::vector modelObjects = m.getModelObjects(); + boost::optional modelObject; boost::optional> body = this->lines(); if (body.is_initialized()) { @@ -348,15 +343,10 @@ namespace detail { found = 1; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); - //TODO cant get below to work so try the manual way - //m.getModelObjects(&uid); - if (modelObjects.size() > 0) { - for (size_t k = 0; k < modelObjects.size(); k++) { - if (modelObjects.at(k).handle() == uid) { - found++; - }; - } - }; + modelObject = m.getModelObject(uid); + if (modelObject) { + found++; + } } //possible uid NOT found in model if (found == 1) { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index bcf2c3a8377..3efa070dfc5 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -92,5 +92,17 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); EXPECT_EQ(meter, meter_sensor.outputMeter()); EXPECT_EQ("", meter_sensor.keyName().get()); + + ASSERT_TRUE(OATdbSensor.outputVariable()); + ASSERT_FALSE(OATdbSensor.outputMeter()); + siteOutdoorAirDrybulbTemperature.remove(); + ASSERT_FALSE(OATdbSensor.outputVariable()); + ASSERT_FALSE(OATdbSensor.outputMeter()); + + ASSERT_TRUE(meter_sensor.outputMeter()); + ASSERT_FALSE(meter_sensor.outputVariable()); + meter.remove(); + ASSERT_FALSE(meter_sensor.outputVariable()); + ASSERT_FALSE(meter_sensor.outputMeter()); } From efce78bc946ce268ca9ef75a12d4f022cd1c7d4c Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 29 Sep 2016 10:31:21 -0600 Subject: [PATCH 135/159] cleanup --- .../src/utilities/idf/Workspace.cpp | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 317980d7231..6cfacb59ccc 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -1924,13 +1924,7 @@ namespace detail { } std::tuple, std::string> Workspace_Impl::getNameSuffix(const std::string& objectName) const { - //Mark method - //std::size_t found = objectName.find_last_of(' '); - //if (found == string::npos) { - // found = objectName.find_last_of('_'); - //} - //Dan method - + std::size_t found1 = objectName.find_last_of(' '); std::size_t found2 = objectName.find_last_of('_'); std::size_t found = string::npos; @@ -1964,13 +1958,7 @@ namespace detail { } std::string Workspace_Impl::getBaseName(const std::string& objectName) const { - //Mark method - //std::size_t found = objectName.find_last_of(' '); - //if (found == string::npos) { - // found = objectName.find_last_of('_'); - //} - //Dan method - + std::size_t found1 = objectName.find_last_of(' '); std::size_t found2 = objectName.find_last_of('_'); std::size_t found = string::npos; @@ -1993,10 +1981,6 @@ namespace detail { ++count; } if (suffix > 0 && count == strSuffix.size() ) { - //debugging end name space issues - //std::string temp = objectName.substr(0, found); - //int size_temp = temp.size(); - //int size = objectName.size(); return objectName.substr(0, found); } } From 288cdb9740fccb6e33a7ae5520dc0b15bb4bf1f2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Thu, 29 Sep 2016 16:39:04 -0600 Subject: [PATCH 136/159] remove leading whitespace from programs --- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 4 ++++ .../src/model/EnergyManagementSystemSubroutine.cpp | 4 ++++ .../src/model/test/EnergyManagementSystemProgram_GTest.cpp | 6 +++--- .../model/test/EnergyManagementSystemSubroutine_GTest.cpp | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 7bfd2213267..eb426323b9d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -139,6 +139,8 @@ namespace detail { if (comments.size() > 0) { //remove whitespace at end of comments[0] boost::trim_right(comments[0]); + //remove whitespace at beginning of comments[0] + boost::trim_left(comments[0]); //insert program line result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); //check if comments exist @@ -208,6 +210,8 @@ namespace detail { if (comments.size() > 0) { //remove whitespace at end of comments[0] boost::trim_right(comments[0]); + //remove whitespace at beginning of comments[0] + boost::trim_left(comments[0]); //insert program line result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); //check if comments exist diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 570bc4f9b22..10094d8757d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -136,6 +136,8 @@ namespace detail { if (comments.size() > 0) { //remove whitespace at end of comments[0] boost::trim_right(comments[0]); + //remove whitespace at beginning of comments[0] + boost::trim_left(comments[0]); //insert program line result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); //check if comments exist @@ -204,6 +206,8 @@ namespace detail { if (comments.size() > 0) { //remove whitespace at end of comments[0] boost::trim_right(comments[0]); + //remove whitespace at beginning of comments[0] + boost::trim_left(comments[0]); //insert program line result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); //check if comments exist diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 9a4566ce261..96a27f68645 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -81,7 +81,7 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) std::string programName = fan.name().get() + "Pressure_Rise_Program_by_Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + std::string fan_program_1_body = " SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\n SET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; //this is what the body should look like with 2 /n's and compare TRUE std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //the added lines should compare TRUE to below @@ -120,8 +120,8 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) programName = fan.name().get() + "Pressure Rise Program by Line"; fan_program_2.setName(programName); //create program by individual lines - std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; - std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + std::string line1 = " SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = " SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; fan_program_2.addLine(line1); fan_program_2.addLine(line2); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp index c7171196c5e..93dcebd34b5 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp @@ -82,7 +82,7 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) std::string programName = fan.name().get() + "Pressure Rise Program by Body"; fan_program_1.setName(programName); //this body has /r/n in it - std::string fan_program_1_body = "SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\nSET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; + std::string fan_program_1_body = " SET mult = " + toString(OATdbSensor.handle() ) + " / 15.0 !- This is nonsense\r\n SET " + toString(fanActuator.handle() ) + " = 250 * mult !- More nonsense"; //this is what the body should look like with 2 /n's and compare TRUE std::string fan_program_body_test = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\nSET " + toString(fanActuator.handle()) + " = 250 * mult !- More nonsense\n"; //the added lines should compare TRUE to below @@ -121,8 +121,8 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) programName = fan.name().get() + "Pressure Rise Program by Line"; fan_program_2.setName(programName); //create program by individual lines - std::string line1 = "SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; - std::string line2 = "SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + std::string line1 = " SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; + std::string line2 = " SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; fan_program_2.addLine(line1); fan_program_2.addLine(line2); From d3744e8ad1dc19ca021cb5ad3dfbf1ace00285d7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 3 Oct 2016 13:43:03 -0600 Subject: [PATCH 137/159] privatize incomplete constructors --- .../src/energyplus/Test/EMS_GTest.cpp | 82 +++++++++---------- .../model/EnergyManagementSystemActuator.hpp | 15 +++- ...EnergyManagementSystemInternalVariable.hpp | 8 +- ...yManagementSystemMeteredOutputVariable.hpp | 9 +- .../EnergyManagementSystemOutputVariable.hpp | 9 +- .../model/EnergyManagementSystemSensor.hpp | 9 +- .../EnergyManagementSystemTrendVariable.hpp | 9 +- .../EnergyManagementSystemActuator_GTest.cpp | 23 ++++-- ...ManagementSystemInternalVariable_GTest.cpp | 4 +- ...ementSystemMeteredOutputVariable_GTest.cpp | 8 +- ...gyManagementSystemOutputVariable_GTest.cpp | 12 +-- ...ementSystemProgramCallingManager_GTest.cpp | 12 ++- .../EnergyManagementSystemProgram_GTest.cpp | 34 ++++---- .../EnergyManagementSystemSensor_GTest.cpp | 12 +-- ...EnergyManagementSystemSubroutine_GTest.cpp | 22 +++-- ...rgyManagementSystemTrendVariable_GTest.cpp | 4 +- 16 files changed, 147 insertions(+), 125 deletions(-) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 2e636543ffc..9689582d148 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -173,9 +173,9 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); // add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -221,9 +221,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensor2_EMS) { OutputVariable lightsElectricPower("Zone Lights Electric Power", model); // add light sensor on zone1 - EnergyManagementSystemSensor lights(model); + EnergyManagementSystemSensor lights(model, lightsElectricPower); lights.setName("Light Sensor"); - lights.setOutputVariable(lightsElectricPower); + // lights.setOutputVariable(lightsElectricPower); lights.setKeyName(zone1.name().get()); ForwardTranslator forwardTranslator; @@ -271,9 +271,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSensoronMeter_EMS) { meter.setMeterFileOnly(false); //add sensor to meter - EnergyManagementSystemSensor meter_sensor(model); + EnergyManagementSystemSensor meter_sensor(model, meter); meter_sensor.setName("meter sensor"); - meter_sensor.setOutputMeter(meter); + //meter_sensor.setOutputMeter(meter); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -318,13 +318,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorActuator_EMS) { FanConstantVolume fan(model, s); // add actuator - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -371,22 +369,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + // OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); //add program EnergyManagementSystemProgram fan_program_1(model); @@ -452,22 +448,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorSubroutine_EMS) { OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor really really really really really long name"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + // OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName + "really really really really really long name"); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName + "really really really really really long name"); //add program EnergyManagementSystemSubroutine fan_program_1(model); @@ -533,22 +527,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); //add program @@ -782,7 +774,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { EXPECT_EQ("glob_var_2", var2.nameString()); // add output variable - EnergyManagementSystemOutputVariable outvar(model); + EnergyManagementSystemOutputVariable outvar(model, "glob_var"); //setname outvar.setName("outputVar"); EXPECT_EQ("outputVar", outvar.nameString()); @@ -791,7 +783,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { EXPECT_EQ(true, varset); // add output variable - EnergyManagementSystemOutputVariable outvar2(model); + EnergyManagementSystemOutputVariable outvar2(model, "glob_var_2"); //setname outvar2.setName("outputVar2"); EXPECT_EQ("outputVar2", outvar2.nameString()); @@ -829,7 +821,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable - EnergyManagementSystemTrendVariable var(model); + EnergyManagementSystemTrendVariable var(model, "glob_var"); var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); var.setEMSVariableName("glob_var"); @@ -868,10 +860,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorInternalVariable_EMS) { Model model; // add internal variable - EnergyManagementSystemInternalVariable var(model); + EnergyManagementSystemInternalVariable var(model, "TestName"); var.setName("Test name"); var.setInternalDataIndexKeyName("TestName"); - var.setInternalDataType("TestName"); + //var.setInternalDataType("TestName"); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -982,9 +974,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); // add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add program EnergyManagementSystemProgram program_1(model); @@ -995,9 +987,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { subroutine_1.setName("subroutine one"); // add metered output variable - EnergyManagementSystemMeteredOutputVariable meteredoutvar(model); + EnergyManagementSystemMeteredOutputVariable meteredoutvar(model, OATdbSensor.name().get()); - meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); + //meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); meteredoutvar.setUpdateFrequency("ZoneTimestep"); meteredoutvar.setEMSProgramorSubroutineName(program_1); meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); @@ -1050,10 +1042,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable - EnergyManagementSystemTrendVariable var(model); + EnergyManagementSystemTrendVariable var(model, "glob_var"); var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); - var.setEMSVariableName("glob_var"); + //var.setEMSVariableName("glob_var"); EXPECT_EQ("glob_var", var.eMSVariableName()); var.setNumberofTimestepstobeLogged(2); @@ -1075,10 +1067,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { emsCIV.setConstructionObject(construction); // add trend variable - EnergyManagementSystemTrendVariable var2(model); + EnergyManagementSystemTrendVariable var2(model, emsCIV.name().get()); var2.setName("TestName2"); EXPECT_EQ("TestName2", var2.name().get()); - var2.setEMSVariableName(emsCIV.name().get()); + //var2.setEMSVariableName(emsCIV.name().get()); EXPECT_EQ(emsCIV.name().get(), var2.eMSVariableName()); var2.setNumberofTimestepstobeLogged(3); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index 0fbbd8da1da..eeadd84169d 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -24,6 +24,11 @@ #include "ModelObject.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} + namespace model { namespace detail { @@ -40,10 +45,6 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { explicit EnergyManagementSystemActuator(const ModelObject& modelObject, std::string actuatedComponentType, std::string actuatedComponentControlType); - explicit EnergyManagementSystemActuator(const ModelObject& modelObject); - - explicit EnergyManagementSystemActuator(const Model& model); - virtual ~EnergyManagementSystemActuator() {} //@} @@ -84,9 +85,15 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemActuator"); + //These are for the ReveseTranslator + explicit EnergyManagementSystemActuator(const ModelObject& modelObject); + + explicit EnergyManagementSystemActuator(const Model& model); + }; /** \relates EnergyManagementSystemActuator*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp index 65e100d30a5..cee18026153 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -24,6 +24,10 @@ #include "ModelObject.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} namespace model { namespace detail { @@ -39,8 +43,6 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { //@{ explicit EnergyManagementSystemInternalVariable(const Model& model, std::string internalDataType); - explicit EnergyManagementSystemInternalVariable(const Model& model); - virtual ~EnergyManagementSystemInternalVariable() {} //@} @@ -79,9 +81,11 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemInternalVariable"); + explicit EnergyManagementSystemInternalVariable(const Model& model); }; /** \relates EnergyManagementSystemInternalVariable*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index ecafc56bb36..af7e79bb2ad 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -26,6 +26,11 @@ #include "EnergyManagementSystemSubroutine.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} + namespace model { namespace detail { @@ -42,8 +47,6 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model); - virtual ~EnergyManagementSystemMeteredOutputVariable() {} //@} @@ -120,9 +123,11 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemMeteredOutputVariable"); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model); }; /** \relates EnergyManagementSystemMeteredOutputVariable*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index 4a7ebf2b169..530a0a45ca2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -26,6 +26,11 @@ #include "EnergyManagementSystemSubroutine.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} + namespace model { namespace detail { @@ -41,8 +46,6 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { //@{ explicit EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName); - explicit EnergyManagementSystemOutputVariable(const Model& model); - virtual ~EnergyManagementSystemOutputVariable() {} //@} @@ -101,9 +104,11 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemOutputVariable"); + explicit EnergyManagementSystemOutputVariable(const Model& model); }; /** \relates EnergyManagementSystemOutputVariable*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index 3203226ac3a..7954ec6f18c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -28,6 +28,11 @@ #include "OutputMeter_Impl.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} + namespace model { class OutputVariable; @@ -45,8 +50,6 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemSensor(const Model& model); - explicit EnergyManagementSystemSensor(const Model& model, OutputVariable& outvar); explicit EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar); @@ -92,9 +95,11 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemSensor"); + explicit EnergyManagementSystemSensor(const Model& model); }; /** \relates EnergyManagementSystemSensor*/ diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp index ea2320af09d..99b9c83a6d2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -24,6 +24,11 @@ #include "ModelObject.hpp" namespace openstudio { + +namespace energyplus { + class ReverseTranslator; +} + namespace model { namespace detail { @@ -39,8 +44,6 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { //@{ explicit EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName); - explicit EnergyManagementSystemTrendVariable(const Model& model); - virtual ~EnergyManagementSystemTrendVariable() {} //@} @@ -77,9 +80,11 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { friend class Model; friend class IdfObject; friend class openstudio::detail::IdfObject_Impl; + friend class energyplus::ReverseTranslator; /// @endcond private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemTrendVariable"); + explicit EnergyManagementSystemTrendVariable(const Model& model); }; /** \relates EnergyManagementSystemTrendVariable*/ diff --git a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp index 263b3798079..f630306819b 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemActuator_GTest.cpp @@ -61,16 +61,20 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) FanConstantVolume fan2(model, s); // add actuator - EnergyManagementSystemActuator fanActuator(fan); + std::string fanControlType = "Fan Pressure Rise"; + std::string ComponentType = "Fan"; + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); + EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); + std::string fanName = fan.name().get() + "Press Actuator"; fanActuator.setName(fanName); - std::string fanControlType = "Fan Pressure Rise"; + fanActuator.setActuatedComponentControlType(fanControlType); EXPECT_EQ(fan, fanActuator.actuatedComponent()); EXPECT_EQ(fanControlType, fanActuator.actuatedComponentControlType()); - - std::string ComponentType = "Fan"; + fanActuator.setActuatedComponentType(ComponentType); EXPECT_EQ(ComponentType, fanActuator.actuatedComponentType()); @@ -80,19 +84,22 @@ TEST_F(ModelFixture, EMSActuator_EMSActuator) //add electric equipment actuator ElectricEquipmentDefinition definition(model); ElectricEquipment electricEquipment(definition); - EnergyManagementSystemActuator equipActuator(electricEquipment); + ComponentType = "ElectricEquipment"; + std::string equipControlType = "Electric Power Level"; + EnergyManagementSystemActuator equipActuator(electricEquipment, ComponentType, equipControlType); + EXPECT_EQ(equipControlType, equipActuator.actuatedComponentControlType()); + EXPECT_EQ(ComponentType, equipActuator.actuatedComponentType()); + std::string equipName = electricEquipment.name().get() + "power level Actuator"; equipActuator.setName(equipName); - std::string equipControlType = "Electric Power Level"; + equipActuator.setActuatedComponentControlType(equipControlType); EXPECT_EQ(electricEquipment, equipActuator.actuatedComponent()); EXPECT_EQ(equipControlType, equipActuator.actuatedComponentControlType()); - ComponentType = "ElectricEquipment"; equipActuator.setActuatedComponentType(ComponentType); EXPECT_EQ(ComponentType, equipActuator.actuatedComponentType()); - } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp index 809bda9a310..0d93a5b0257 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp @@ -39,12 +39,12 @@ TEST_F(ModelFixture, EMSInternalVariable_EMSInternalVariable) Model model; // add internal variable - EnergyManagementSystemInternalVariable var(model); + EnergyManagementSystemInternalVariable var(model, "TestName"); var.setInternalDataIndexKeyName("TestName"); EXPECT_EQ("TestName", var.internalDataIndexKeyName().get()); var.resetInternalDataIndexKeyName(); EXPECT_EQ("", var.internalDataIndexKeyName().get()); - var.setInternalDataType("TestName"); + //var.setInternalDataType("TestName"); EXPECT_EQ("TestName", var.internalDataType()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp index 4530b6b8902..c13bc9db318 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -46,9 +46,9 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); // add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add program EnergyManagementSystemProgram program_1(model); @@ -59,9 +59,9 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) subroutine_1.setName("subroutine one"); // add metered output variable - EnergyManagementSystemMeteredOutputVariable meteredoutvar(model); + EnergyManagementSystemMeteredOutputVariable meteredoutvar(model, OATdbSensor.name().get()); - meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); + //meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); EXPECT_EQ(meteredoutvar.eMSVariableName(), OATdbSensor.name().get()); meteredoutvar.setUpdateFrequency("ZoneTimestep"); EXPECT_EQ("ZoneTimestep",meteredoutvar.updateFrequency()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 92b69484e1c..b2444f8ba47 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -65,9 +65,9 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); // add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); // add fan Schedule s = model.alwaysOnDiscreteSchedule(); @@ -75,14 +75,14 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) FanConstantVolume fan2(model, s); // add actuator - EnergyManagementSystemActuator fanActuator(fan); + std::string fanControlType = "Fan Pressure Rise"; + std::string ComponentType = "Fan"; + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); std::string fanName = fan.name().get() + "Press Actuator"; fanActuator.setName(fanName); - std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); // add output variable - EnergyManagementSystemOutputVariable outvar(model); + EnergyManagementSystemOutputVariable outvar(model, "globalVar"); //setname outvar.setName("outputVar"); EXPECT_EQ("outputVar", outvar.nameString()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp index 8a3f0f35f9a..f14981b0354 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp @@ -60,22 +60,20 @@ TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); FanConstantVolume fan(model, s); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press Actuator"; + fanActuator.setName(fanName); //add program EnergyManagementSystemProgram fan_program_1(model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 96a27f68645..8d766b891bb 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -58,9 +58,9 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); @@ -68,13 +68,11 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) fan.setName("fan"); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Pressure_Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Pressure_Actuator"; + fanActuator.setName(fanName); //add program EnergyManagementSystemProgram fan_program_1(model); @@ -109,11 +107,11 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); //add actuator on fan again - EnergyManagementSystemActuator fanActuator2(fan); + fanControlType = "Fan Pressure Rise"; + ComponentType = "Fan"; + EnergyManagementSystemActuator fanActuator2(fan, ComponentType, fanControlType); fanName = fan.name().get() + "Press_Actuator"; fanActuator2.setName(fanName); - fanControlType = "Fan Pressure Rise"; - fanActuator2.setActuatedComponentControlType(fanControlType); // Create a second program from a vector of lines EnergyManagementSystemProgram fan_program_2(model); @@ -150,9 +148,9 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); //add sensor back in - EnergyManagementSystemSensor OATdbSensor2(model); + EnergyManagementSystemSensor OATdbSensor2(model, siteOutdoorAirDrybulbTemperature); OATdbSensor2.setName("OATdb Sensor"); - OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); + // OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); // # Create a third program from vector of lines EnergyManagementSystemProgram fan_program_3(model); @@ -272,9 +270,9 @@ TEST_F(ModelFixture, EMSProgramUid_EMSProgramUid) { OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); @@ -282,13 +280,11 @@ TEST_F(ModelFixture, EMSProgramUid_EMSProgramUid) { fan.setName("fan"); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Pressure_Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Pressure_Actuator"; + fanActuator.setName(fanName); //add program EnergyManagementSystemProgram fan_program_1(model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 3efa070dfc5..1172442cf95 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -56,9 +56,9 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("Site Outdoor Air Drybulb Temperature", siteOutdoorAirDrybulbTemperature.variableName()); // add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + //OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); EXPECT_EQ("OATdb_Sensor", OATdbSensor.nameString()); EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle() ); @@ -71,9 +71,9 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("Zone Lights Electric Power", lightsElectricPower.variableName()); // add light sensor on zone1 - EnergyManagementSystemSensor lights(model); + EnergyManagementSystemSensor lights(model, lightsElectricPower); lights.setName("Light Sensor"); - lights.setOutputVariable(lightsElectricPower); + //lights.setOutputVariable(lightsElectricPower); lights.setKeyName(zone1.name().get()); EXPECT_EQ(zone1.name().get(), lights.keyName().get()); @@ -84,9 +84,9 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) meter.setName("test meter"); //add sensor to meter - EnergyManagementSystemSensor meter_sensor(model); + EnergyManagementSystemSensor meter_sensor(model, meter); meter_sensor.setName("meter sensor"); - meter_sensor.setOutputMeter(meter); + //meter_sensor.setOutputMeter(meter); EXPECT_EQ("meter_sensor", meter_sensor.nameString()); EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp index 93dcebd34b5..f5ca0a1de33 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp @@ -59,9 +59,9 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) OutputVariable siteOutdoorAirDrybulbTemperature("Site Outdoor Air Drybulb Temperature", model); //add sensor - EnergyManagementSystemSensor OATdbSensor(model); + EnergyManagementSystemSensor OATdbSensor(model, siteOutdoorAirDrybulbTemperature); OATdbSensor.setName("OATdb Sensor"); - OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); + // OATdbSensor.setOutputVariable(siteOutdoorAirDrybulbTemperature); //add fan Schedule s = model.alwaysOnDiscreteSchedule(); @@ -69,13 +69,11 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) fan.setName("fan"); //add actuator on fan - EnergyManagementSystemActuator fanActuator(fan); - std::string fanName = fan.name().get() + "Press_Actuator"; - fanActuator.setName(fanName); std::string fanControlType = "Fan Pressure Rise"; - fanActuator.setActuatedComponentControlType(fanControlType); std::string ComponentType = "Fan"; - fanActuator.setActuatedComponentType(ComponentType); + EnergyManagementSystemActuator fanActuator(fan, ComponentType, fanControlType); + std::string fanName = fan.name().get() + "Press_Actuator"; + fanActuator.setName(fanName); //add program EnergyManagementSystemSubroutine fan_program_1(model); @@ -110,11 +108,11 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) EXPECT_EQ(1, fan_program_1.invalidReferencedObjects().size()); //add actuator on fan again - EnergyManagementSystemActuator fanActuator2(fan); + fanControlType = "Fan Pressure Rise"; + ComponentType = "Fan"; + EnergyManagementSystemActuator fanActuator2(fan, ComponentType, fanControlType); fanName = fan.name().get() + "Press_Actuator"; fanActuator2.setName(fanName); - fanControlType = "Fan Pressure Rise"; - fanActuator2.setActuatedComponentControlType(fanControlType); // Create a second program from a vector of lines EnergyManagementSystemSubroutine fan_program_2(model); @@ -151,9 +149,9 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) EXPECT_EQ(1, fan_program_2.invalidReferencedObjects().size()); //add sensor back in - EnergyManagementSystemSensor OATdbSensor2(model); + EnergyManagementSystemSensor OATdbSensor2(model, siteOutdoorAirDrybulbTemperature); OATdbSensor2.setName("OATdb Sensor"); - OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); + // OATdbSensor2.setOutputVariable(siteOutdoorAirDrybulbTemperature); // # Create a third program from vector of lines EnergyManagementSystemSubroutine fan_program_3(model); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index 72f9ba9f8d2..16ee07d6cd1 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -43,10 +43,10 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) EnergyManagementSystemGlobalVariable globvar(model, "glob var"); // add trend variable - EnergyManagementSystemTrendVariable var(model); + EnergyManagementSystemTrendVariable var(model, "glob_var"); var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); - var.setEMSVariableName("glob_var"); + //var.setEMSVariableName("glob_var"); EXPECT_EQ("glob_var", var.eMSVariableName()); var.setNumberofTimestepstobeLogged(2); From 886e7df730ba3abb9a3cf9f70253eac1e558478e Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 3 Oct 2016 15:52:34 -0600 Subject: [PATCH 138/159] cleanup --- .../src/model/EnergyManagementSystemInternalVariable.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp index cee18026153..1139abb71cc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -28,6 +28,7 @@ namespace openstudio { namespace energyplus { class ReverseTranslator; } + namespace model { namespace detail { From a3ccc944a3981a9e0555c1ab0f7729bb74dde1da Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 10 Oct 2016 14:18:42 -0600 Subject: [PATCH 139/159] add new constructor for sensor remove commas from programs remove sensors on OutputMeter or OutputVariable deletion --- ...dTranslateEnergyManagementSystemSensor.cpp | 8 +++- ...eTranslateEnergyManagementSystemSensor.cpp | 2 + .../model/EnergyManagementSystemProgram.cpp | 8 ++++ .../model/EnergyManagementSystemSensor.cpp | 41 +++++++++++-------- .../model/EnergyManagementSystemSensor.hpp | 8 ++-- .../EnergyManagementSystemSensor_Impl.hpp | 5 +-- .../EnergyManagementSystemSubroutine.cpp | 8 ++++ openstudiocore/src/model/OutputMeter.cpp | 2 +- openstudiocore/src/model/OutputVariable.cpp | 4 +- .../EnergyManagementSystemSensor_GTest.cpp | 16 ++++++-- 10 files changed, 71 insertions(+), 31 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp index 3fd4f10efbe..9b31ee4d92d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp @@ -62,12 +62,18 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSen d = modelObject.outputVariable(); if (d.is_initialized()) { idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, d.get().variableName()); + return idfObject; } m = modelObject.outputMeter(); if (m.is_initialized()){ idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, m.get().name()); + return idfObject; + } + s = modelObject.outputVariableOrMeterName(); + if (s.is_initialized()) { + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName, s.get()); + return idfObject; } - return idfObject; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp index fe1d3e4af47..226fd002a5b 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp @@ -79,6 +79,8 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con } } } + //set outputVariableOrMeterName to string value + emsSensor.setOutputVariableOrMeterName(s.get()); } s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index eb426323b9d..dbef289777c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -141,6 +141,10 @@ namespace detail { boost::trim_right(comments[0]); //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); + //remove , + while ((pos = comments[0].find(",", pos)) != std::string::npos) { + comments[0].erase(pos, 1); + } //insert program line result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); //check if comments exist @@ -212,6 +216,10 @@ namespace detail { boost::trim_right(comments[0]); //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); + //remove , + while ((pos = comments[0].find(",", pos)) != std::string::npos) { + comments[0].erase(pos, 1); + } //insert program line result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); //check if comments exist diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 6a09461c569..5a5ba8c38f2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -94,6 +94,10 @@ namespace detail { return value.get(); } + boost::optional EnergyManagementSystemSensor_Impl::outputVariableOrMeterName() const { + return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, true); + } + bool EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, keyName); return result; @@ -105,21 +109,15 @@ namespace detail { return result; } - bool EnergyManagementSystemSensor_Impl::resetOutputMeter() { + bool EnergyManagementSystemSensor_Impl::setOutputMeter(const OutputMeter& outputMeter) { //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); - bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, ""); - return result; - } - - bool EnergyManagementSystemSensor_Impl::resetOutputVariable() { - //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariable.handle()); - bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, ""); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, toString(outputMeter.handle())); return result; } - bool EnergyManagementSystemSensor_Impl::setOutputMeter(const OutputMeter& outputMeter) { + bool EnergyManagementSystemSensor_Impl::setOutputVariableOrMeterName(const std::string& outputVariableOrMeterName) { //bool result = setPointer(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputMeter.handle()); - bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, toString(outputMeter.handle())); + bool result = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariableOrMeterName); return result; } @@ -183,6 +181,17 @@ EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, O } } +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, const std::string& outputVariableOrMeterName) + : ModelObject(EnergyManagementSystemSensor::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, outputVariableOrMeterName); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s OutputVariableOrMeterName to " + << outputVariableOrMeterName << "."); + } +} + EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model) : ModelObject(EnergyManagementSystemSensor::iddObjectType(),model) { @@ -206,6 +215,10 @@ boost::optional EnergyManagementSystemSensor::outputMeter() const { return getImpl()->outputMeter(); } +boost::optional EnergyManagementSystemSensor::outputVariableOrMeterName() const { + return getImpl()->outputVariableOrMeterName(); +} + bool EnergyManagementSystemSensor::setKeyName(const std::string& keyName) { return getImpl()->setKeyName(keyName); } @@ -218,12 +231,8 @@ bool EnergyManagementSystemSensor::setOutputMeter(const OutputMeter& outputMeter return getImpl()->setOutputMeter(outputMeter); } -bool EnergyManagementSystemSensor::resetOutputVariable() { - return getImpl()->resetOutputVariable(); -} - -bool EnergyManagementSystemSensor::resetOutputMeter() { - return getImpl()->resetOutputMeter(); +bool EnergyManagementSystemSensor::setOutputVariableOrMeterName(const std::string& outputVariableOrMeterName) { + return getImpl()->setOutputVariableOrMeterName(outputVariableOrMeterName); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index 7954ec6f18c..db80dff263e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -54,6 +54,8 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { explicit EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar); + explicit EnergyManagementSystemSensor(const Model& model, const std::string& outputVariableOrMeterName); + virtual ~EnergyManagementSystemSensor() {} //@} @@ -67,6 +69,7 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { boost::optional outputVariable() const; boost::optional outputMeter() const; + boost::optional outputVariableOrMeterName() const; //@} /** @name Setters */ @@ -76,10 +79,7 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); - - bool resetOutputVariable(); - bool resetOutputMeter(); - + bool setOutputVariableOrMeterName(const std::string& outputVariableOrMeterName); //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 03da0a112c8..82f5deabffa 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -71,6 +71,7 @@ namespace detail { boost::optional outputVariable() const; boost::optional outputMeter() const; + boost::optional outputVariableOrMeterName() const; //@} /** @name Setters */ @@ -80,9 +81,7 @@ namespace detail { bool setOutputVariable(const OutputVariable& outputVariable); bool setOutputMeter(const OutputMeter& outputMeter); - - bool resetOutputVariable(); - bool resetOutputMeter(); + bool setOutputVariableOrMeterName(const std::string& outputVariableOrMeterName); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 10094d8757d..5b7e3f88d4e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -138,6 +138,10 @@ namespace detail { boost::trim_right(comments[0]); //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); + //remove , + while ((pos = comments[0].find(",", pos)) != std::string::npos) { + comments[0].erase(pos, 1); + } //insert program line result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); //check if comments exist @@ -208,6 +212,10 @@ namespace detail { boost::trim_right(comments[0]); //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); + //remove , + while ((pos = comments[0].find(",", pos)) != std::string::npos) { + comments[0].erase(pos, 1); + } //insert program line result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); //check if comments exist diff --git a/openstudiocore/src/model/OutputMeter.cpp b/openstudiocore/src/model/OutputMeter.cpp index 3ef07e897f6..6b8522b55da 100644 --- a/openstudiocore/src/model/OutputMeter.cpp +++ b/openstudiocore/src/model/OutputMeter.cpp @@ -117,7 +117,7 @@ namespace detail { for (auto & sensor : objects) { if (sensor.outputMeter()) { if (sensor.outputMeter().get().name() == this->name()) { - sensor.resetOutputMeter(); + sensor.remove(); } } } diff --git a/openstudiocore/src/model/OutputVariable.cpp b/openstudiocore/src/model/OutputVariable.cpp index 270a90d9951..7f650afac03 100644 --- a/openstudiocore/src/model/OutputVariable.cpp +++ b/openstudiocore/src/model/OutputVariable.cpp @@ -101,8 +101,8 @@ namespace detail { std::vector objects = m.getModelObjects(); for (auto & sensor : objects) { if (sensor.outputVariable()) { - if (sensor.outputVariable().get().variableName() == this->name()) { - sensor.resetOutputVariable(); + if (sensor.outputVariable().get().variableName() == this->variableName()) { + sensor.remove(); } } } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 1172442cf95..4479c63c25d 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -28,6 +28,7 @@ #include "../OutputVariable_Impl.hpp" #include "../OutputMeter.hpp" #include "../OutputMeter_Impl.hpp" +#include "../Model.hpp" #include "../Model_Impl.hpp" #include "../../utilities/idd/IddEnums.hpp" @@ -96,13 +97,20 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) ASSERT_TRUE(OATdbSensor.outputVariable()); ASSERT_FALSE(OATdbSensor.outputMeter()); siteOutdoorAirDrybulbTemperature.remove(); - ASSERT_FALSE(OATdbSensor.outputVariable()); - ASSERT_FALSE(OATdbSensor.outputMeter()); + boost::optional object = model.getModelObjectByName("OATdb_Sensor"); + ASSERT_FALSE(object); ASSERT_TRUE(meter_sensor.outputMeter()); ASSERT_FALSE(meter_sensor.outputVariable()); meter.remove(); - ASSERT_FALSE(meter_sensor.outputVariable()); - ASSERT_FALSE(meter_sensor.outputMeter()); + object = model.getModelObjectByName("meter sensor"); + ASSERT_FALSE(object); + + // add sensor by string + EnergyManagementSystemSensor sensor_string(model, "Sensor String"); + sensor_string.setName("Sensor String Name"); + EXPECT_EQ("Sensor_String_Name", sensor_string.nameString()); + ASSERT_TRUE(sensor_string.outputVariableOrMeterName()); + EXPECT_EQ("Sensor String", sensor_string.outputVariableOrMeterName().get()); } From e9dd15193afa9d98399a88e7035f7d3cab4c08af Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 10 Oct 2016 14:31:30 -0600 Subject: [PATCH 140/159] fix sensor RT --- ...everseTranslateEnergyManagementSystemSensor.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp index 226fd002a5b..852e9c5fa17 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemSensor.cpp @@ -51,6 +51,11 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con Workspace workspace = workspaceObject.workspace(); + s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName); + if (s) { + emsSensor.setKeyName(*s); + } + s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterName); if (s) { //look for Output:Variables named *s @@ -61,7 +66,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con if (outvar) { if (outvar.get().variableName() == s) { emsSensor.setOutputVariable(outvar.get()); - break; + return emsSensor; } } } @@ -74,7 +79,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con if (outvar) { if (outvar.get().name() == s) { emsSensor.setOutputMeter(outvar.get()); - break; + return emsSensor; } } } @@ -83,11 +88,6 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemSensor(con emsSensor.setOutputVariableOrMeterName(s.get()); } - s = workspaceObject.getString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName); - if(s){ - emsSensor.setKeyName(*s); - } - return emsSensor; } From 723ba6f49f87af20d2dff7b745a2ffe348f31d64 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 10 Oct 2016 20:16:28 -0600 Subject: [PATCH 141/159] typo --- openstudiocore/src/model/EnergyManagementSystemProgram.cpp | 2 ++ openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp | 2 ++ .../src/model/test/EnergyManagementSystemProgram_GTest.cpp | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index dbef289777c..6618cb5d2b1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -142,6 +142,7 @@ namespace detail { //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); //remove , + pos = 0; while ((pos = comments[0].find(",", pos)) != std::string::npos) { comments[0].erase(pos, 1); } @@ -217,6 +218,7 @@ namespace detail { //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); //remove , + pos = 0; while ((pos = comments[0].find(",", pos)) != std::string::npos) { comments[0].erase(pos, 1); } diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 5b7e3f88d4e..0f97b7e8150 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -139,6 +139,7 @@ namespace detail { //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); //remove , + pos = 0; while ((pos = comments[0].find(",", pos)) != std::string::npos) { comments[0].erase(pos, 1); } @@ -213,6 +214,7 @@ namespace detail { //remove whitespace at beginning of comments[0] boost::trim_left(comments[0]); //remove , + pos = 0; while ((pos = comments[0].find(",", pos)) != std::string::npos) { comments[0].erase(pos, 1); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index 8d766b891bb..a4b75cd5019 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -118,8 +118,8 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) programName = fan.name().get() + "Pressure Rise Program by Line"; fan_program_2.setName(programName); //create program by individual lines - std::string line1 = " SET mult = " + toString(OATdbSensor.handle()) + " / 15.0 !- This is nonsense\r\n"; - std::string line2 = " SET " + toString(fanActuator2.handle()) + " = 250 * mult !- More nonsense\r\n"; + std::string line1 = " SET mult = " + toString(OATdbSensor.handle()) + " / 15.0, !- This is nonsense\r\n"; + std::string line2 = " SET " + toString(fanActuator2.handle()) + " = 250 * mult, !- More nonsense\r\n"; fan_program_2.addLine(line1); fan_program_2.addLine(line2); From df9a4d872f7c6ca9838b05122e20e973a73a1c6f Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 11 Oct 2016 09:44:29 -0600 Subject: [PATCH 142/159] EMS outputvariable idd change to string --- openstudiocore/resources/model/OpenStudio.idd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 563d7bef9be..8909ee81ceb 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26553,8 +26553,7 @@ OS:EnergyManagementSystem:OutputVariable, \retaincase A3, \field EMS Variable Name \required-field - \type object-list - \object-list ErlVariableNames + \type alpha \note must be an acceptable EMS variable A4, \field Type of Data in Variable \required-field From 5b79510c53a0ca669c2ada60fca9889a10bae5ac Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 11 Oct 2016 11:48:16 -0600 Subject: [PATCH 143/159] meteredoutputvariable idd change to string --- openstudiocore/resources/model/OpenStudio.idd | 3 +-- .../model/test/EnergyManagementSystemOutputVariable_GTest.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index 85c4f288860..ff76433198f 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26622,8 +26622,7 @@ OS:EnergyManagementSystem:MeteredOutputVariable, \retaincase A3, \field EMS Variable Name \required-field - \type object-list - \object-list ErlVariableNames + \type alpha \note must be an acceptable EMS variable, no spaces A4, \field Update Frequency \required-field diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index b2444f8ba47..714ad926602 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -89,8 +89,7 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) //variable name bool varset = outvar.setEMSVariableName("badVariable"); - //TODO above should fail - EXPECT_EQ(false,varset); + EXPECT_EQ(true,varset); varset = outvar.setEMSVariableName("globalVar"); EXPECT_EQ(true, varset); From 0fdbcde193015332a96b6e3213fe318b81fb7dc7 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 11 Oct 2016 14:40:54 -0600 Subject: [PATCH 144/159] changing object support for outputvariable & meteredOV --- ...yManagementSystemMeteredOutputVariable.cpp | 255 +++++++++++++++++- ...yManagementSystemMeteredOutputVariable.hpp | 39 +++ ...gementSystemMeteredOutputVariable_Impl.hpp | 18 ++ .../EnergyManagementSystemOutputVariable.cpp | 245 ++++++++++++++++- .../EnergyManagementSystemOutputVariable.hpp | 40 +++ ...rgyManagementSystemOutputVariable_Impl.hpp | 20 ++ ...gyManagementSystemOutputVariable_GTest.cpp | 12 + 7 files changed, 625 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 74cf36e369c..b57f5a2f76f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -23,6 +23,20 @@ #include "EnergyManagementSystemProgram_Impl.hpp" #include "EnergyManagementSystemSubroutine.hpp" #include "EnergyManagementSystemSubroutine_Impl.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" +#include "EnergyManagementSystemActuator_Impl.hpp" +#include "EnergyManagementSystemGlobalVariable_Impl.hpp" +#include "EnergyManagementSystemTrendVariable_Impl.hpp" +#include "EnergyManagementSystemInternalVariable_Impl.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" #include #include @@ -111,6 +125,41 @@ namespace detail { return result; } + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemActuator& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemSensor& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + bool EnergyManagementSystemMeteredOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, updateFrequency); return result; @@ -166,6 +215,46 @@ namespace detail { OS_ASSERT(result); } + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableObject() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional< EnergyManagementSystemActuator> EnergyManagementSystemMeteredOutputVariable_Impl::emsActuator() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional< EnergyManagementSystemSensor> EnergyManagementSystemMeteredOutputVariable_Impl::emsSensor() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsGlobalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsTrendVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsInternalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsCurveOrTableIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsConstructionIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + return value; + } + } // detail EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName) @@ -182,6 +271,111 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemActuator& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemSensor& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) + : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("SystemTimestep"); + setResourceType("Electricity"); + setGroupType("Building"); + setEndUseCategory("Fans"); +} + EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(),model) { @@ -249,8 +443,33 @@ boost::optional EnergyManagementSystemMeteredOutputVariable::units( return getImpl()->units(); } -bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { - return getImpl()->setEMSVariableName(eMSVariableName); + +boost::optional EnergyManagementSystemMeteredOutputVariable::eMSVariableObject() const { + return getImpl()->eMSVariableObject(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsActuator() const { + return getImpl()->emsActuator(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsGlobalVariable() const { + return getImpl()->emsGlobalVariable(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsTrendVariable() const { + return getImpl()->emsTrendVariable(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsInternalVariable() const { + return getImpl()->emsInternalVariable(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsCurveOrTableIndexVariable() const { + return getImpl()->emsCurveOrTableIndexVariable(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsConstructionIndexVariable() const { + return getImpl()->emsConstructionIndexVariable(); } bool EnergyManagementSystemMeteredOutputVariable::setUpdateFrequency(const std::string& updateFrequency) { @@ -297,6 +516,38 @@ void EnergyManagementSystemMeteredOutputVariable::resetUnits() { getImpl()->resetUnits(); } +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + return getImpl()->setEMSVariableName(eMSVariableName); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemActuator& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemSensor& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemMeteredOutputVariable::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + /// @cond EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index af7e79bb2ad..025714b0f46 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -24,6 +24,13 @@ #include "ModelObject.hpp" #include "EnergyManagementSystemProgram.hpp" #include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" namespace openstudio { @@ -47,6 +54,20 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemActuator& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemSensor& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + virtual ~EnergyManagementSystemMeteredOutputVariable() {} //@} @@ -80,6 +101,16 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject boost::optional units() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + //@} /** @name Setters */ //@{ @@ -108,6 +139,14 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject void resetUnits(); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp index b02a0ad4e19..624d23e100f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp @@ -78,6 +78,16 @@ namespace detail { boost::optional units() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + //@} /** @name Setters */ //@{ @@ -106,6 +116,14 @@ namespace detail { void resetUnits(); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 667a724f6cc..14e62340fa6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -23,6 +23,20 @@ #include "EnergyManagementSystemProgram_Impl.hpp" #include "EnergyManagementSystemSubroutine.hpp" #include "EnergyManagementSystemSubroutine_Impl.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" +#include "EnergyManagementSystemActuator_Impl.hpp" +#include "EnergyManagementSystemGlobalVariable_Impl.hpp" +#include "EnergyManagementSystemTrendVariable_Impl.hpp" +#include "EnergyManagementSystemInternalVariable_Impl.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" #include #include @@ -97,6 +111,41 @@ namespace detail { return result; } + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemActuator& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemSensor& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + bool EnergyManagementSystemOutputVariable_Impl::setTypeofDatainVariable(const std::string& typeofDatainVariable) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable, typeofDatainVariable); return result; @@ -132,6 +181,46 @@ namespace detail { OS_ASSERT(result); } + boost::optional EnergyManagementSystemOutputVariable_Impl::eMSVariableObject() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional< EnergyManagementSystemActuator> EnergyManagementSystemOutputVariable_Impl::emsActuator() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional< EnergyManagementSystemSensor> EnergyManagementSystemOutputVariable_Impl::emsSensor() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsGlobalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsTrendVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsInternalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsCurveOrTableIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsConstructionIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + return value; + } + } // detail EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName) @@ -145,6 +234,98 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const setUpdateFrequency("ZoneTimestep"); setTypeofDatainVariable("Averaged"); } + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemActuator& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemSensor& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) + : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setUpdateFrequency("ZoneTimestep"); + setTypeofDatainVariable("Averaged"); +} + EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(),model) { @@ -188,8 +369,36 @@ boost::optional EnergyManagementSystemOutputVariable::units() const return getImpl()->units(); } -bool EnergyManagementSystemOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { - return getImpl()->setEMSVariableName(eMSVariableName); +boost::optional EnergyManagementSystemOutputVariable::eMSVariableObject() const { + return getImpl()->eMSVariableObject(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsActuator() const { + return getImpl()->emsActuator(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsSensor() const { + return getImpl()->emsSensor(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsGlobalVariable() const { + return getImpl()->emsGlobalVariable(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsTrendVariable() const { + return getImpl()->emsTrendVariable(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsInternalVariable() const { + return getImpl()->emsInternalVariable(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsCurveOrTableIndexVariable() const { + return getImpl()->emsCurveOrTableIndexVariable(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsConstructionIndexVariable() const { + return getImpl()->emsConstructionIndexVariable(); } bool EnergyManagementSystemOutputVariable::setTypeofDatainVariable(const std::string& typeofDatainVariable) { @@ -220,6 +429,38 @@ void EnergyManagementSystemOutputVariable::resetUnits() { getImpl()->resetUnits(); } +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const std::string& eMSVariableName) { + return getImpl()->setEMSVariableName(eMSVariableName); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemActuator& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemSensor& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemOutputVariable::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + /// @cond EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index 530a0a45ca2..5d8fa2ac97a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -24,6 +24,13 @@ #include "ModelObject.hpp" #include "EnergyManagementSystemProgram.hpp" #include "EnergyManagementSystemSubroutine.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" namespace openstudio { @@ -46,6 +53,20 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { //@{ explicit EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemActuator& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemSensor& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + + explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + virtual ~EnergyManagementSystemOutputVariable() {} //@} @@ -69,6 +90,16 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { boost::optional units() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + //@} /** @name Setters */ //@{ @@ -89,6 +120,15 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { void resetUnits(); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp index 04a9f969a84..c4100037de7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp @@ -70,6 +70,17 @@ namespace detail { boost::optional units() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + + //@} /** @name Setters */ //@{ @@ -90,6 +101,15 @@ namespace detail { void resetUnits(); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index 714ad926602..add253e074d 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -127,5 +127,17 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) EXPECT_EQ("program_1", outvar.eMSProgramorSubroutineName().get()); + // add output variable actuator + EnergyManagementSystemOutputVariable outvar_act(model, fanActuator); + //setname + outvar_act.setName("outputVar act"); + EXPECT_EQ("outputVar act", outvar_act.nameString()); + + // add output variable sensor + EnergyManagementSystemOutputVariable outvar_sen(model, OATdbSensor); + //setname + outvar_sen.setName("outputVar sen"); + EXPECT_EQ("outputVar sen", outvar_sen.nameString()); + } From 4e9b611a5230a8bbe02d79af5c2771351b0960b2 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 11 Oct 2016 15:23:42 -0600 Subject: [PATCH 145/159] add object support for TrendVariable emsVariableName --- .../EnergyManagementSystemTrendVariable.cpp | 229 ++++++++++++++++++ .../EnergyManagementSystemTrendVariable.hpp | 39 +++ ...ergyManagementSystemTrendVariable_Impl.hpp | 18 ++ 3 files changed, 286 insertions(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index 2d44e78839d..d10800dec20 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -19,6 +19,20 @@ #include "EnergyManagementSystemTrendVariable.hpp" #include "EnergyManagementSystemTrendVariable_Impl.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemSensor_Impl.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" +#include "EnergyManagementSystemActuator_Impl.hpp" +#include "EnergyManagementSystemGlobalVariable_Impl.hpp" +#include "EnergyManagementSystemTrendVariable_Impl.hpp" +#include "EnergyManagementSystemInternalVariable_Impl.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" #include #include @@ -69,6 +83,45 @@ namespace detail { return value.get(); } + boost::optional EnergyManagementSystemTrendVariable_Impl::eMSVariableObject() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + boost::optional< EnergyManagementSystemActuator> EnergyManagementSystemTrendVariable_Impl::emsActuator() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional< EnergyManagementSystemSensor> EnergyManagementSystemTrendVariable_Impl::emsSensor() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemTrendVariable_Impl::emsGlobalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemTrendVariable_Impl::emsTrendVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemTrendVariable_Impl::emsInternalVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemTrendVariable_Impl::emsCurveOrTableIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + + boost::optional EnergyManagementSystemTrendVariable_Impl::emsConstructionIndexVariable() const { + boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); + return value; + } + int EnergyManagementSystemTrendVariable_Impl::numberofTimestepstobeLogged() const { boost::optional value = getInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged,true); return value.get(); @@ -79,6 +132,42 @@ namespace detail { return result; } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemActuator& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemSensor& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + + bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + return result; + } + bool EnergyManagementSystemTrendVariable_Impl::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { bool result = setInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, numberofTimestepstobeLogged); return result; @@ -97,6 +186,85 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M setNumberofTimestepstobeLogged(1); } +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemActuator& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} + +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemSensor& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemTrendVariable& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemInternalVariable& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) + : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { + OS_ASSERT(getImpl()); + bool ok = setEMSVariableName(object); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " + << object.briefDescription() << "."); + } + setNumberofTimestepstobeLogged(1); +} + EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { @@ -113,6 +281,38 @@ std::string EnergyManagementSystemTrendVariable::eMSVariableName() const { return getImpl()->eMSVariableName(); } +boost::optional EnergyManagementSystemTrendVariable::emsActuator() const { + return getImpl()->emsActuator(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsSensor() const { + return getImpl()->emsSensor(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsGlobalVariable() const { + return getImpl()->emsGlobalVariable(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsTrendVariable() const { + return getImpl()->emsTrendVariable(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsInternalVariable() const { + return getImpl()->emsInternalVariable(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsCurveOrTableIndexVariable() const { + return getImpl()->emsCurveOrTableIndexVariable(); +} + +boost::optional EnergyManagementSystemTrendVariable::emsConstructionIndexVariable() const { + return getImpl()->emsConstructionIndexVariable(); +} + +boost::optional EnergyManagementSystemTrendVariable::eMSVariableObject() const { + return getImpl()->eMSVariableObject(); +} + int EnergyManagementSystemTrendVariable::numberofTimestepstobeLogged() const { return getImpl()->numberofTimestepstobeLogged(); } @@ -121,6 +321,35 @@ bool EnergyManagementSystemTrendVariable::setEMSVariableName(const std::string& return getImpl()->setEMSVariableName(eMSVariableName); } + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemActuator& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemSensor& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + +bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { + return getImpl()->setEMSVariableName(object); +} + bool EnergyManagementSystemTrendVariable::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { return getImpl()->setNumberofTimestepstobeLogged(numberofTimestepstobeLogged); } diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp index 99b9c83a6d2..2d6828f1f01 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -22,6 +22,13 @@ #include #include "ModelObject.hpp" +#include "EnergyManagementSystemActuator.hpp" +#include "EnergyManagementSystemSensor.hpp" +#include "EnergyManagementSystemGlobalVariable.hpp" +#include "EnergyManagementSystemTrendVariable.hpp" +#include "EnergyManagementSystemInternalVariable.hpp" +#include "EnergyManagementSystemCurveOrTableIndexVariable.hpp" +#include "EnergyManagementSystemConstructionIndexVariable.hpp" namespace openstudio { @@ -44,6 +51,20 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { //@{ explicit EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemActuator& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemSensor& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + + explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + virtual ~EnergyManagementSystemTrendVariable() {} //@} @@ -57,6 +78,16 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { int numberofTimestepstobeLogged() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + //@} /** @name Setters */ //@{ @@ -65,6 +96,14 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp index 0983c91bbda..1aed80ceddc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp @@ -64,6 +64,16 @@ namespace detail { int numberofTimestepstobeLogged() const; + boost::optional eMSVariableObject() const; + + boost::optional emsActuator() const; + boost::optional emsSensor() const; + boost::optional emsGlobalVariable() const; + boost::optional emsTrendVariable() const; + boost::optional emsInternalVariable() const; + boost::optional emsCurveOrTableIndexVariable() const; + boost::optional emsConstructionIndexVariable() const; + //@} /** @name Setters */ //@{ @@ -72,6 +82,14 @@ namespace detail { bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + bool setEMSVariableName(const EnergyManagementSystemActuator& object); + bool setEMSVariableName(const EnergyManagementSystemSensor& object); + bool setEMSVariableName(const EnergyManagementSystemGlobalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemTrendVariable& object); + bool setEMSVariableName(const EnergyManagementSystemInternalVariable& object); + bool setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object); + bool setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object); + //@} /** @name Other */ //@{ From a688bfdce1140c2632304c2e777a6459185952bf Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 12 Oct 2016 10:33:33 -0600 Subject: [PATCH 146/159] add missing function link --- .../src/model/EnergyManagementSystemMeteredOutputVariable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index b57f5a2f76f..303b20b3374 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -452,6 +452,10 @@ boost::optional EnergyManagementSystemMeteredOut return getImpl()->emsActuator(); } +boost::optional EnergyManagementSystemMeteredOutputVariable::emsSensor() const { + return getImpl()->emsSensor(); +} + boost::optional EnergyManagementSystemMeteredOutputVariable::emsGlobalVariable() const { return getImpl()->emsGlobalVariable(); } From 8bedb77ad16a3582e9e82bab4a29bcb0cc528d15 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 12 Oct 2016 14:18:56 -0600 Subject: [PATCH 147/159] fixing methods changed from object to alpha's --- ...yManagementSystemMeteredOutputVariable.cpp | 58 ++++++++++++++++--- .../EnergyManagementSystemOutputVariable.cpp | 58 ++++++++++++++++--- .../EnergyManagementSystemTrendVariable.cpp | 14 ++--- ...ementSystemMeteredOutputVariable_GTest.cpp | 10 ++++ ...gyManagementSystemOutputVariable_GTest.cpp | 4 ++ ...rgyManagementSystemTrendVariable_GTest.cpp | 12 ++++ 6 files changed, 133 insertions(+), 23 deletions(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 303b20b3374..f65707ab4b9 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -38,6 +38,8 @@ #include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" #include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" +#include "Model.hpp" + #include #include #include @@ -216,42 +218,82 @@ namespace detail { } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableObject() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional< EnergyManagementSystemActuator> EnergyManagementSystemMeteredOutputVariable_Impl::emsActuator() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional< EnergyManagementSystemSensor> EnergyManagementSystemMeteredOutputVariable_Impl::emsSensor() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsGlobalVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsTrendVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsInternalVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsCurveOrTableIndexVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsConstructionIndexVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 14e62340fa6..75417b6ca13 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -38,6 +38,8 @@ #include "EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" #include "EnergyManagementSystemConstructionIndexVariable_Impl.hpp" +#include "Model.hpp" + #include #include #include @@ -182,42 +184,82 @@ namespace detail { } boost::optional EnergyManagementSystemOutputVariable_Impl::eMSVariableObject() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional< EnergyManagementSystemActuator> EnergyManagementSystemOutputVariable_Impl::emsActuator() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional< EnergyManagementSystemSensor> EnergyManagementSystemOutputVariable_Impl::emsSensor() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemOutputVariable_Impl::emsGlobalVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemOutputVariable_Impl::emsTrendVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemOutputVariable_Impl::emsInternalVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemOutputVariable_Impl::emsCurveOrTableIndexVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } boost::optional EnergyManagementSystemOutputVariable_Impl::emsConstructionIndexVariable() const { - boost::optional value = this->getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName)->cast(); + boost::optional value; + boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); + if (handle) { + const Model m = this->model(); + value = m.getModelObject(toUUID(handle.get())); + } return value; } diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index d10800dec20..ec2aa649ed8 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -134,37 +134,37 @@ namespace detail { bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemActuator& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemSensor& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemGlobalVariable& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemTrendVariable& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemInternalVariable& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemCurveOrTableIndexVariable& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } bool EnergyManagementSystemTrendVariable_Impl::setEMSVariableName(const EnergyManagementSystemConstructionIndexVariable& object) { - bool result = setString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, toString(object.handle())); + bool result = setPointer(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName, object.handle()); return result; } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp index c13bc9db318..a3e7b714e2e 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -81,5 +81,15 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) EXPECT_EQ("Madeup", meteredoutvar.endUseSubcategory().get()); model.save(toPath("./EMS_meteredoutvar.osm"), true); + + // add output variable sensor + EnergyManagementSystemMeteredOutputVariable outvar_sen(model, OATdbSensor); + //setname + outvar_sen.setName("outputVar sen"); + EXPECT_EQ("outputVar sen", outvar_sen.nameString()); + + ASSERT_TRUE(outvar_sen.eMSVariableObject()); + ASSERT_TRUE(outvar_sen.emsSensor()); + EXPECT_EQ(outvar_sen.eMSVariableObject().get(), outvar_sen.emsSensor().get()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index add253e074d..f86c9ad5e3c 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -139,5 +139,9 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) outvar_sen.setName("outputVar sen"); EXPECT_EQ("outputVar sen", outvar_sen.nameString()); + ASSERT_TRUE(outvar_sen.eMSVariableObject()); + ASSERT_TRUE(outvar_sen.emsSensor()); + EXPECT_EQ(outvar_sen.eMSVariableObject().get(), outvar_sen.emsSensor().get()); + } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index 16ee07d6cd1..f84bac54a73 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -51,5 +51,17 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) var.setNumberofTimestepstobeLogged(2); EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + + EXPECT_EQ(globvar,var.emsGlobalVariable().get()); + + // add global variable + EnergyManagementSystemGlobalVariable globvar2(model, "glob var2"); + + EnergyManagementSystemTrendVariable var2(model, globvar2); + EXPECT_EQ("glob_var2", var2.eMSVariableName()); + ASSERT_TRUE(var2.eMSVariableObject()); + ASSERT_TRUE(var2.emsGlobalVariable()); + EXPECT_EQ(globvar2, var2.emsGlobalVariable().get()); + EXPECT_EQ(var2.eMSVariableObject().get(), var2.emsGlobalVariable().get()); } From 93a108bd1b7a784b73d81e7c687f2b9bf7597480 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 14 Oct 2016 15:57:59 -0600 Subject: [PATCH 148/159] cleanup --- openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index ec2aa649ed8..d70c9064bce 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -269,7 +269,6 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - //TODO setEMSVariableName to a valid default setNumberofTimestepstobeLogged(1); } From 54df6b61317503fa55f36bf149d456f6f9068fd8 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Fri, 14 Oct 2016 16:07:40 -0600 Subject: [PATCH 149/159] cleanup --- .../model/test/EnergyManagementSystemOutputVariable_GTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index f86c9ad5e3c..bf20e55e586 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -135,7 +135,7 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) // add output variable sensor EnergyManagementSystemOutputVariable outvar_sen(model, OATdbSensor); - //setname + outvar_sen.setName("outputVar sen"); EXPECT_EQ("outputVar sen", outvar_sen.nameString()); From abb39d853b63b5cd9161b269ab03571df161b3ef Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 10:22:51 -0600 Subject: [PATCH 150/159] idd cleanup remove m_map.insert from FT change log error to warn --- openstudiocore/resources/model/OpenStudio.idd | 28 +++++++++---------- ...teEnergyManagementSystemGlobalVariable.cpp | 2 +- ...TranslateEnergyManagementSystemProgram.cpp | 2 +- ...nslateEnergyManagementSystemSubroutine.cpp | 2 +- ...ranslateEnergyManagementSystemActuator.cpp | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/openstudiocore/resources/model/OpenStudio.idd b/openstudiocore/resources/model/OpenStudio.idd index ff76433198f..1446577524c 100644 --- a/openstudiocore/resources/model/OpenStudio.idd +++ b/openstudiocore/resources/model/OpenStudio.idd @@ -26449,7 +26449,7 @@ OS:EnergyManagementSystem:Sensor, \min-fields 4 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26463,7 +26463,7 @@ OS:EnergyManagementSystem:Sensor, A4; \field Output Variable or Output Meter Name \required-field \type alpha - + OS:EnergyManagementSystem:Actuator, \memo Hardware portion of EMS used to set up actuators in the model \min-fields 4 @@ -26486,7 +26486,7 @@ OS:EnergyManagementSystem:Actuator, \type alpha A5; \field Actuated Component Control Type \required-field - \type alpha + \type alpha OS:EnergyManagementSystem:ProgramCallingManager, \extensible:1 - repeat last field, remembering to remove ; from "inner" fields. @@ -26496,7 +26496,7 @@ OS:EnergyManagementSystem:ProgramCallingManager, \min-fields 4 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26533,7 +26533,7 @@ OS:EnergyManagementSystem:Program, \min-fields 3 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26552,7 +26552,7 @@ OS:EnergyManagementSystem:Subroutine, \min-fields 3 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26563,18 +26563,18 @@ OS:EnergyManagementSystem:Subroutine, \begin-extensible \type alpha \required-field - + OS:EnergyManagementSystem:GlobalVariable, \memo Declares Erl variable as having global scope \memo No spaces allowed in names used for Erl variables \min-fields 2 A1, \field Handle \type handle - \required-field + \required-field A2; \field Name \required-field \type alpha - \reference ErlVariableNames + \reference ErlVariableNames \note no spaces allowed in name OS:EnergyManagementSystem:OutputVariable, @@ -26716,7 +26716,7 @@ OS:EnergyManagementSystem:TrendVariable, A3, \field EMS Variable Name \required-field \type object-list - \object-list ErlVariableNames + \object-list ErlVariableNames \note must be a global scope EMS variable N1; \field Number of Timesteps to be Logged \required-field @@ -26728,7 +26728,7 @@ OS:EnergyManagementSystem:InternalVariable, \min-fields 4 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26746,7 +26746,7 @@ OS:EnergyManagementSystem:CurveOrTableIndexVariable, \min-fields 3 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26763,7 +26763,7 @@ OS:EnergyManagementSystem:ConstructionIndexVariable, \min-fields 3 A1, \field Handle \type handle - \required-field + \required-field A2, \field Name \required-field \type alpha @@ -26773,5 +26773,5 @@ OS:EnergyManagementSystem:ConstructionIndexVariable, A3; \field Construction Object Name \type object-list \object-list ConstructionNames - \required-field + \required-field diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp index 0d8f9129ef7..7b5972a57e8 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemGlobalVariable.cpp @@ -49,7 +49,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemGlo //TODO add all the global variables to one object in the IDF IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_GlobalVariable); m_idfObjects.push_back(idfObject); - m_map.insert(std::make_pair(modelObject.handle(), idfObject)); + //m_map.insert(std::make_pair(modelObject.handle(), idfObject)); //AddErlVariable s = modelObject.name(); diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp index a84201372b5..38362390133 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemProgram.cpp @@ -57,7 +57,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemPro IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Program); m_idfObjects.push_back(idfObject); - m_map.insert(std::make_pair(modelObject.handle(), idfObject)); + //m_map.insert(std::make_pair(modelObject.handle(), idfObject)); //Name s = modelObject.name(); if (s) { diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp index 5d5d7731590..fdcfebf62aa 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSubroutine.cpp @@ -57,7 +57,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSub IdfObject idfObject(openstudio::IddObjectType::EnergyManagementSystem_Subroutine); m_idfObjects.push_back(idfObject); - m_map.insert(std::make_pair(modelObject.handle(), idfObject)); + //m_map.insert(std::make_pair(modelObject.handle(), idfObject)); //Name s = modelObject.name(); if (s) { diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp index 1c7e77785cf..db952c751b2 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp @@ -71,7 +71,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(c } return emsActuator; } else { - LOG(Error, "ATTENTION: Actuated Object " + wsObject.nameString() + " does not reverse translate. ActuatedComponent is NOT set."); + LOG(Warn, "ATTENTION: Actuated Object " + wsObject.nameString() + " does not reverse translate. ActuatedComponent is NOT set."); openstudio::model::EnergyManagementSystemActuator emsActuator(m_model); OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); emsActuator.setName(*s1); From 1fa8d402e98d179d7bb1402541eed6f0e7fdea9b Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 11:29:03 -0600 Subject: [PATCH 151/159] trapping size != 1 cases in RT actuator --- ...rseTranslateEnergyManagementSystemActuator.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp index db952c751b2..aec409b84c9 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemActuator.cpp @@ -54,8 +54,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(c Workspace workspace = workspaceObject.workspace(); if (s) { - for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { - boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + std::vector wsObjects = workspace.getObjectsByName(*s); + if (wsObjects.size() > 1) { + LOG(Error, workspaceObject.nameString() + ": ActuatedComponentUniqueName is not unique. More than 1 object with that name."); + return boost::none; + } + if (wsObjects.size() == 0) { + LOG(Error, workspaceObject.nameString() + ": ActuatedComponentUniqueName not found."); + return boost::none; + } else { + //ActuatedComponent's name is unique so we can continue and try to translate that object. + boost::optional modelObject = translateAndMapWorkspaceObject(wsObjects[0]); if (modelObject) { openstudio::model::EnergyManagementSystemActuator emsActuator(modelObject.get()); emsActuator.setName(*s1); @@ -71,7 +80,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemActuator(c } return emsActuator; } else { - LOG(Warn, "ATTENTION: Actuated Object " + wsObject.nameString() + " does not reverse translate. ActuatedComponent is NOT set."); + LOG(Warn, "ATTENTION: Actuated Object " + wsObjects[0].nameString() + " does not reverse translate. ActuatedComponent is NOT set."); openstudio::model::EnergyManagementSystemActuator emsActuator(m_model); OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ActuatorFields::Name); emsActuator.setName(*s1); From 244c9f92bf1860a6eec66ebacc101bcc62a18562 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 12:53:30 -0600 Subject: [PATCH 152/159] trap construction RT --- ...gyManagementSystemConstructionIndexVariable.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp index b314d4d69e6..a6bc7185e11 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp @@ -21,6 +21,7 @@ #include "../../model/EnergyManagementSystemConstructionIndexVariable.hpp" #include "../../model/EnergyManagementSystemConstructionIndexVariable_Impl.hpp" +//#include "../../model/Construction.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -54,8 +55,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructi Workspace workspace = workspaceObject.workspace(); if (s) { - for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { - boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + //std::vector wsObjects = workspace.getObjectsByTypeAndName(IddObjectType::Construction, *s); + std::vector wsObjects = workspace.getObjectsByName(*s); + if (wsObjects.size() > 1) { + LOG(Error, workspaceObject.nameString() + ": Construction is not unique. More than 1 object with that name."); + return boost::none; + } + if (wsObjects.size() == 0) { + LOG(Error, workspaceObject.nameString() + ": Construction not found."); + return boost::none; + } else { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObjects[0]); if (modelObject) { openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model); emsConstructionIndexVariable.setName(*s1); From ff3e92326ee93b5ba7757100b04b6945a36c2076 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 12:57:48 -0600 Subject: [PATCH 153/159] trap CurveorTableObject RT --- ...rgyManagementSystemCurveOrTableIndexVariable.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp index 68a6d5634d5..4397db36c24 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -54,8 +54,17 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTab Workspace workspace = workspaceObject.workspace(); if (s) { - for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { - boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + //for ( WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { + std::vector wsObjects = workspace.getObjectsByName(*s); + if (wsObjects.size() > 1) { + LOG(Error, workspaceObject.nameString() + ": CurveorTableObject is not unique. More than 1 object with that name."); + return boost::none; + } + if (wsObjects.size() == 0) { + LOG(Error, workspaceObject.nameString() + ": CurveorTableObject not found."); + return boost::none; + } else { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObjects[0]); if (modelObject) { openstudio::model::EnergyManagementSystemCurveOrTableIndexVariable emsCurveOrTableIndexVariable(m_model); emsCurveOrTableIndexVariable.setName(*s1); From 5e47726dd90ced7a60f261936a61d684ed587c1d Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 14:17:56 -0600 Subject: [PATCH 154/159] catch invalid emsVariable in meteredOutputVariable use getObjectByTypeAndName in OutputVariable add Gtest for multiple GVs --- ...rgyManagementSystemMeteredOutputVariable.cpp | 17 +++++++++++++---- ...lateEnergyManagementSystemOutputVariable.cpp | 7 ++++--- .../src/energyplus/Test/EMS_GTest.cpp | 13 +++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 47cba3ebc83..05dc56be05d 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -129,14 +129,19 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set"); return boost::none; } else { + bool result = false; Workspace workspace = workspaceObject.workspace(); //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { if (modelObject.get().cast().name() == s) { - emsOutputVariable.setEMSVariableName(*s); - return emsOutputVariable; + result = emsOutputVariable.setEMSVariableName(*s); + if (result) { + return emsOutputVariable; + } else { + return boost::none; + } } } } @@ -144,8 +149,12 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { - emsOutputVariable.setEMSVariableName(*s); - return emsOutputVariable; + result = emsOutputVariable.setEMSVariableName(*s); + if (result) { + return emsOutputVariable; + } else { + return boost::none; + } } } } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp index 433248a4576..d7c303701a3 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -71,12 +71,13 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari } else { Workspace workspace = workspaceObject.workspace(); //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. - for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { - boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); + boost::optional wsObject = workspace.getObjectByTypeAndName(IddObjectType::EnergyManagementSystem_GlobalVariable, *s); + //for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { + if (wsObject) { + boost::optional modelObject = translateAndMapWorkspaceObject(wsObject.get()); if (modelObject) { if (modelObject.get().cast().name() == s) { emsOutputVariable.setEMSVariableName(*s); - break; } } } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 9689582d148..7ab52cc3136 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -762,6 +762,19 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorGlobalVariable_EMS) { } +/* +TEST_F(EnergyPlusFixture, ReverseTranslatorGlobalVariable2_EMS) { + + openstudio::path idfPath = toPath("./EMS_GlobalVariable2.idf"); + OptionalIdfFile idfFile = IdfFile::load(idfPath, IddFileType::EnergyPlus); + ASSERT_TRUE(idfFile); + Workspace inWorkspace(*idfFile); + ReverseTranslator reverseTranslator; + Model model = reverseTranslator.translateWorkspace(inWorkspace); + model.save(toPath("./EMS_GlobalVariable2T.osm"), true); + +} +*/ TEST_F(EnergyPlusFixture, ForwardTranslatorOutputVariable_EMS) { Model model; From ede30445fa3c99982d2677b7aecda99320b8c27c Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Tue, 18 Oct 2016 14:30:52 -0600 Subject: [PATCH 155/159] trap non emsVariable in RT TrendVariable --- ...slateEnergyManagementSystemTrendVariable.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp index 3cf979e2a2a..904604dde43 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp @@ -63,14 +63,19 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria LOG(Error, emsTrendVariable.nameString() + ": EMSVariableName not set"); return boost::none; } else { + bool result = false; Workspace workspace = workspaceObject.workspace(); //look for GlobalVariables, translate and check if there is a name match since GV's dont have name field. for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { if (modelObject.get().cast().name() == s) { - emsTrendVariable.setEMSVariableName(*s); - return emsTrendVariable; + result = emsTrendVariable.setEMSVariableName(*s); + if (result) { + return emsTrendVariable; + } else { + return boost::none; + } } } } @@ -78,8 +83,12 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) { boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { - emsTrendVariable.setEMSVariableName(*s); - return emsTrendVariable; + result = emsTrendVariable.setEMSVariableName(*s); + if (result) { + return emsTrendVariable; + } else { + return boost::none; + } } } } From 7aacb3df4f96b6a7bd985defd89761724a0c7179 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 19 Oct 2016 08:27:49 -0600 Subject: [PATCH 156/159] various pull request changes change meteredoutvar to /objectlist --- openstudiocore/src/energyplus/Test/EMS_GTest.cpp | 2 +- ...rgyManagementSystemCurveOrTableIndexVariable.hpp | 2 +- ...nagementSystemCurveOrTableIndexVariable_Impl.hpp | 2 +- .../EnergyManagementSystemMeteredOutputVariable.cpp | 10 +++++++++- .../model/EnergyManagementSystemOutputVariable.cpp | 9 ++++++++- .../model/EnergyManagementSystemOutputVariable.hpp | 4 ++++ .../src/model/EnergyManagementSystemProgram.cpp | 13 ++++--------- openstudiocore/src/model/ModelCore.i | 4 ++-- openstudiocore/src/model/OutputMeter.cpp | 2 +- openstudiocore/src/model/OutputVariable.cpp | 2 +- ...yManagementSystemMeteredOutputVariable_GTest.cpp | 2 +- 11 files changed, 33 insertions(+), 19 deletions(-) diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 7ab52cc3136..b42d0d4a770 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -1106,4 +1106,4 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorTrendVariable2_EMS) { Model model = reverseTranslator.translateWorkspace(inWorkspace); model.save(toPath("./EMS_TrendVariable2T.osm"), true); -} \ No newline at end of file +} diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp index 4cc08642ee7..37aea348d97 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp @@ -28,7 +28,7 @@ namespace openstudio { namespace model { // TODO: Check the following class names against object getters and setters. -class AllCurves; +class Curves; namespace detail { diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp index c76ca5a15a1..cb838719acc 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp @@ -27,7 +27,7 @@ namespace openstudio { namespace model { // TODO: Check the following class names against object getters and setters. -class AllCurves; +class Curves; namespace detail { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index f65707ab4b9..72f4840be8c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -86,6 +86,7 @@ namespace detail { } std::string EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableName() const { + //TODO call emsVAriableObject() return .nameString() boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName,true); return value.get(); } @@ -96,7 +97,13 @@ namespace detail { } boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSProgramorSubroutineName() const { - return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName,true); + //return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName,true); + boost::optional object = getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName); + if (object) { + return object.get().nameString(); + } + boost::optional temp; + return temp; } std::string EnergyManagementSystemMeteredOutputVariable_Impl::resourceType() const { @@ -179,6 +186,7 @@ namespace detail { void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, ""); + //bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, NULL); OS_ASSERT(result); } diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index 75417b6ca13..c81024b9ab6 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -101,7 +101,13 @@ namespace detail { } boost::optional EnergyManagementSystemOutputVariable_Impl::eMSProgramorSubroutineName() const { - return getString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName,true); + //return getString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName,true); + boost::optional object = getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName); + if (object) { + return object.get().nameString(); + } + boost::optional temp; + return temp; } boost::optional EnergyManagementSystemOutputVariable_Impl::units() const { @@ -170,6 +176,7 @@ namespace detail { void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, ""); + //bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, NULL); OS_ASSERT(result); } diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index 5d8fa2ac97a..409d65a9ce9 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -87,6 +87,10 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { std::string updateFrequency() const; boost::optional eMSProgramorSubroutineName() const; + //TODO + //boost::optional eMSProgram() const; + + //boost::optional eMSSubroutine() const; boost::optional units() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index 6618cb5d2b1..e6e6508bfe1 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -352,24 +352,19 @@ namespace detail { if (body.is_initialized()) { //assume body is a vector of strings for (size_t i = 0; i < body.get().size(); i++) { - int found = 0; //find uids boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); while (j != boost::sregex_token_iterator()) { possible_uid = *j++; - found = 1; //look to see if uid is in the model and return the object UUID uid = toUUID(possible_uid); modelObject = m.getModelObject(uid); - if (modelObject) { - found++; + if (!modelObject) { + result.push_back(body.get().at(i)); + break; } - } - //possible uid NOT found in model - if (found == 1) { - result.push_back(body.get().at(i)); - }; + } } } return result; diff --git a/openstudiocore/src/model/ModelCore.i b/openstudiocore/src/model/ModelCore.i index 92614c1e199..937584815a7 100644 --- a/openstudiocore/src/model/ModelCore.i +++ b/openstudiocore/src/model/ModelCore.i @@ -182,7 +182,7 @@ MODELOBJECT_TEMPLATES(EnergyManagementSystemSubroutine); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgram); MODELOBJECT_TEMPLATES(EnergyManagementSystemProgramCallingManager); MODELOBJECT_TEMPLATES(EnergyManagementSystemOutputVariable); -MODELOBJECT_TEMPLATES(OutputEnergyManagementSystem); +UNIQUEMODELOBJECT_TEMPLATES(OutputEnergyManagementSystem); SWIG_MODELOBJECT(ModelObject, 0); SWIG_MODELEXTENSIBLEGROUP(ModelExtensibleGroup); @@ -221,6 +221,6 @@ SWIG_MODELOBJECT(EnergyManagementSystemSubroutine, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgram, 1); SWIG_MODELOBJECT(EnergyManagementSystemProgramCallingManager, 1); SWIG_MODELOBJECT(EnergyManagementSystemOutputVariable, 1); -SWIG_MODELOBJECT(OutputEnergyManagementSystem, 1); +SWIG_UNIQUEMODELOBJECT(OutputEnergyManagementSystem); #endif //MODEL_CORE_I diff --git a/openstudiocore/src/model/OutputMeter.cpp b/openstudiocore/src/model/OutputMeter.cpp index 6b8522b55da..85f37195a33 100644 --- a/openstudiocore/src/model/OutputMeter.cpp +++ b/openstudiocore/src/model/OutputMeter.cpp @@ -113,7 +113,7 @@ namespace detail { // Instead, doing an /alpha getString implementation so we need to manually remove any referring Sensors const Model m = this->model(); - std::vector objects = m.getModelObjects(); + std::vector objects = m.getConcreteModelObjects(); for (auto & sensor : objects) { if (sensor.outputMeter()) { if (sensor.outputMeter().get().name() == this->name()) { diff --git a/openstudiocore/src/model/OutputVariable.cpp b/openstudiocore/src/model/OutputVariable.cpp index 7f650afac03..328e89d4322 100644 --- a/openstudiocore/src/model/OutputVariable.cpp +++ b/openstudiocore/src/model/OutputVariable.cpp @@ -98,7 +98,7 @@ namespace detail { // Instead, doing an /alpha getString implementation so we need to manually remove any referring Sensors const Model m = this->model(); - std::vector objects = m.getModelObjects(); + std::vector objects = m.getConcreteModelObjects(); for (auto & sensor : objects) { if (sensor.outputVariable()) { if (sensor.outputVariable().get().variableName() == this->variableName()) { diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp index a3e7b714e2e..56ceafe9dec 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -68,7 +68,7 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) meteredoutvar.setEMSProgramorSubroutineName(program_1); EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); meteredoutvar.resetEMSProgramorSubroutineName(); - EXPECT_EQ("", meteredoutvar.eMSProgramorSubroutineName().get()); + EXPECT_FALSE(meteredoutvar.eMSProgramorSubroutineName()); meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); EXPECT_EQ(subroutine_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); meteredoutvar.setResourceType("NaturalGas"); From 4ce25fbba00004f60b784d69ba454fd654eff4d5 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 19 Oct 2016 12:05:47 -0600 Subject: [PATCH 157/159] name changes and cleanup --- ...agementSystemCurveOrTableIndexVariable.cpp | 2 +- ...yManagementSystemMeteredOutputVariable.cpp | 4 +- ...teEnergyManagementSystemOutputVariable.cpp | 6 +- ...ateEnergyManagementSystemTrendVariable.cpp | 4 +- ...agementSystemCurveOrTableIndexVariable.cpp | 10 +- ...yManagementSystemMeteredOutputVariable.cpp | 4 +- ...teEnergyManagementSystemOutputVariable.cpp | 6 +- ...ateEnergyManagementSystemTrendVariable.cpp | 2 +- .../src/energyplus/Test/EMS_GTest.cpp | 26 ++-- .../model/EnergyManagementSystemActuator.cpp | 2 +- .../model/EnergyManagementSystemActuator.hpp | 2 +- ...agementSystemConstructionIndexVariable.cpp | 2 +- ...agementSystemConstructionIndexVariable.hpp | 2 +- ...agementSystemCurveOrTableIndexVariable.cpp | 22 ++-- ...agementSystemCurveOrTableIndexVariable.hpp | 10 +- ...ntSystemCurveOrTableIndexVariable_Impl.hpp | 9 +- ...EnergyManagementSystemInternalVariable.cpp | 12 +- ...EnergyManagementSystemInternalVariable.hpp | 4 +- ...yManagementSystemInternalVariable_Impl.hpp | 2 +- ...yManagementSystemMeteredOutputVariable.cpp | 102 ++++++++++----- ...yManagementSystemMeteredOutputVariable.hpp | 36 ++--- ...gementSystemMeteredOutputVariable_Impl.hpp | 20 +-- .../EnergyManagementSystemOutputVariable.cpp | 123 +++++++++++------- .../EnergyManagementSystemOutputVariable.hpp | 42 +++--- ...rgyManagementSystemOutputVariable_Impl.hpp | 22 ++-- .../model/EnergyManagementSystemProgram.cpp | 40 ++---- .../model/EnergyManagementSystemProgram.hpp | 6 +- ...yManagementSystemProgramCallingManager.cpp | 48 +------ ...yManagementSystemProgramCallingManager.hpp | 5 +- ...gementSystemProgramCallingManager_Impl.hpp | 6 +- .../EnergyManagementSystemProgram_Impl.hpp | 6 +- .../model/EnergyManagementSystemSensor.cpp | 24 ++-- .../model/EnergyManagementSystemSensor.hpp | 8 +- .../EnergyManagementSystemSensor_Impl.hpp | 4 +- .../EnergyManagementSystemSubroutine.cpp | 40 ++---- .../EnergyManagementSystemSubroutine.hpp | 6 +- .../EnergyManagementSystemSubroutine_Impl.hpp | 6 +- .../EnergyManagementSystemTrendVariable.cpp | 58 ++++----- .../EnergyManagementSystemTrendVariable.hpp | 24 ++-- ...ergyManagementSystemTrendVariable_Impl.hpp | 8 +- ...tSystemCurveOrTableIndexVariable_GTest.cpp | 2 +- ...ManagementSystemInternalVariable_GTest.cpp | 4 +- ...ementSystemMeteredOutputVariable_GTest.cpp | 22 ++-- ...gyManagementSystemOutputVariable_GTest.cpp | 22 ++-- ...ementSystemProgramCallingManager_GTest.cpp | 6 +- .../EnergyManagementSystemProgram_GTest.cpp | 2 +- .../EnergyManagementSystemSensor_GTest.cpp | 9 +- ...EnergyManagementSystemSubroutine_GTest.cpp | 2 +- ...rgyManagementSystemTrendVariable_GTest.cpp | 12 +- 49 files changed, 433 insertions(+), 413 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp index e4217055565..678b46d7dfe 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -53,7 +53,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemCur idfObject.setName(*s); } - idfObject.setString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, modelObject.curveorTableObject().nameString()); + idfObject.setString(EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, modelObject.curveOrTableObject().nameString()); return idfObject; } diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 1cebe07f57c..3f5d60cc53c 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -53,11 +53,11 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemMet idfObject.setName(*s); } - idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, modelObject.eMSVariableName()); + idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, modelObject.emsVariableName()); idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::UpdateFrequency, modelObject.updateFrequency()); - s = modelObject.eMSProgramorSubroutineName(); + s = modelObject.emsProgramOrSubroutineName(); if (s.is_initialized()) { idfObject.setString(EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, s.get()); } diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp index ce67f7cb21c..4d7c366449a 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemOutputVariable.cpp @@ -54,11 +54,11 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemOut if (s) { idfObject.setName(*s); } - s = modelObject.eMSVariableName(); + s = modelObject.emsVariableName(); if (s) { idfObject.setString(EnergyManagementSystem_OutputVariableFields::EMSVariableName, s.get()); } - s = modelObject.typeofDatainVariable(); + s = modelObject.typeOfDataInVariable(); if (s.is_initialized()) { idfObject.setString(EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable, s.get()); } @@ -66,7 +66,7 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemOut if (s.is_initialized()){ idfObject.setString(EnergyManagementSystem_OutputVariableFields::UpdateFrequency, s.get()); } - m = modelObject.eMSProgramorSubroutineName(); + m = modelObject.emsProgramOrSubroutineName(); if (m.is_initialized()) { idfObject.setString(EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, m.get()); } diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp index c50c0154c05..ad7e7c7153d 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemTrendVariable.cpp @@ -54,11 +54,11 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemTre if (s) { idfObject.setName(*s); } - s = modelObject.eMSVariableName(); + s = modelObject.emsVariableName(); if (s) { idfObject.setString(EnergyManagementSystem_TrendVariableFields::EMSVariableName, s.get()); } - i = modelObject.numberofTimestepstobeLogged(); + i = modelObject.numberOfTimestepsToBeLogged(); if (i.is_initialized()) { idfObject.setInt(EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, i.get()); } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp index 4397db36c24..e0beb873b31 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -21,6 +21,8 @@ #include "../../model/EnergyManagementSystemCurveOrTableIndexVariable.hpp" #include "../../model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp" +#include "../../model/Curve.hpp" +#include "../../model/Curve_Impl.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -68,8 +70,12 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemCurveOrTab if (modelObject) { openstudio::model::EnergyManagementSystemCurveOrTableIndexVariable emsCurveOrTableIndexVariable(m_model); emsCurveOrTableIndexVariable.setName(*s1); - emsCurveOrTableIndexVariable.setCurveorTableObject(modelObject.get()); - return emsCurveOrTableIndexVariable; + boost::optional curve = modelObject.get().optionalCast(); + if (curve) { + emsCurveOrTableIndexVariable.setCurveOrTableObject(curve.get()); + return emsCurveOrTableIndexVariable; + } + return boost::none; } } } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp index 05dc56be05d..8a3b0682aa8 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemMeteredOutputVariable.cpp @@ -114,10 +114,10 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemMeteredOut if (modelObject) { if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Program) { EnergyManagementSystemProgram program = modelObject.get().cast(); - emsOutputVariable.setEMSProgramorSubroutineName(program); + emsOutputVariable.setEMSProgramOrSubroutineName(program); } else if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Subroutine) { EnergyManagementSystemSubroutine subroutine = modelObject.get().cast(); - emsOutputVariable.setEMSProgramorSubroutineName(subroutine); + emsOutputVariable.setEMSProgramOrSubroutineName(subroutine); } break; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp index d7c303701a3..2d2074c2120 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemOutputVariable.cpp @@ -104,7 +104,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari LOG(Error, emsOutputVariable.nameString() + ": TypeofDatainVariable not set"); return boost::none; } else { - emsOutputVariable.setTypeofDatainVariable(*s); + emsOutputVariable.setTypeOfDataInVariable(*s); } s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Units); @@ -119,9 +119,9 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVari boost::optional modelObject = translateAndMapWorkspaceObject(wsObject); if (modelObject) { if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Program) { - emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); + emsOutputVariable.setEMSProgramOrSubroutineName(modelObject.get().cast()); } else if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Subroutine) { - emsOutputVariable.setEMSProgramorSubroutineName(modelObject.get().cast()); + emsOutputVariable.setEMSProgramOrSubroutineName(modelObject.get().cast()); } return emsOutputVariable; } diff --git a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp index 904604dde43..a3391a80b05 100644 --- a/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/energyplus/ReverseTranslator/ReverseTranslateEnergyManagementSystemTrendVariable.cpp @@ -55,7 +55,7 @@ OptionalModelObject ReverseTranslator::translateEnergyManagementSystemTrendVaria LOG(Error, emsTrendVariable.nameString() + ": NumberofTimestepstobeLogged not set"); return boost::none; } else { - emsTrendVariable.setNumberofTimestepstobeLogged(*i); + emsTrendVariable.setNumberOfTimestepsToBeLogged(*i); } s = workspaceObject.getString(EnergyManagementSystem_TrendVariableFields::EMSVariableName); diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index b42d0d4a770..2df2b23efc5 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -617,7 +617,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorProgramCallingManager_EMS) { bool callpt = fan_pcm.setCallingPoint("BeginNewEnvironment"); EXPECT_EQ(true, callpt); - EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint().get()); + EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint()); //should start with 0 programs std::vector programs = fan_pcm.programs(); @@ -838,10 +838,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable_EMS) { var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); var.setEMSVariableName("glob_var"); - EXPECT_EQ("glob_var", var.eMSVariableName()); + EXPECT_EQ("glob_var", var.emsVariableName()); - var.setNumberofTimestepstobeLogged(2); - EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + var.setNumberOfTimestepsToBeLogged(2); + EXPECT_EQ(2, var.numberOfTimestepsToBeLogged()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -953,7 +953,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorCurveOrTableIndexVariable_EMS) { CurveBiquadratic c1(model); EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model); - emsCurve.setCurveorTableObject(c1); + emsCurve.setCurveOrTableObject(c1); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); @@ -1004,8 +1004,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorMeteredOutputVariable_EMS) { //meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); meteredoutvar.setUpdateFrequency("ZoneTimestep"); - meteredoutvar.setEMSProgramorSubroutineName(program_1); - meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); + meteredoutvar.setEMSProgramOrSubroutineName(program_1); + meteredoutvar.setEMSProgramOrSubroutineName(subroutine_1); meteredoutvar.setResourceType("NaturalGas"); meteredoutvar.setGroupType("HVAC"); meteredoutvar.setEndUseCategory("Heating"); @@ -1059,10 +1059,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); //var.setEMSVariableName("glob_var"); - EXPECT_EQ("glob_var", var.eMSVariableName()); + EXPECT_EQ("glob_var", var.emsVariableName()); - var.setNumberofTimestepstobeLogged(2); - EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + var.setNumberOfTimestepsToBeLogged(2); + EXPECT_EQ(2, var.numberOfTimestepsToBeLogged()); // Create some materials StandardOpaqueMaterial exterior(model); @@ -1084,10 +1084,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslatorTrendVariable2_EMS) { var2.setName("TestName2"); EXPECT_EQ("TestName2", var2.name().get()); //var2.setEMSVariableName(emsCIV.name().get()); - EXPECT_EQ(emsCIV.name().get(), var2.eMSVariableName()); + EXPECT_EQ(emsCIV.name().get(), var2.emsVariableName()); - var2.setNumberofTimestepstobeLogged(3); - EXPECT_EQ(3, var2.numberofTimestepstobeLogged()); + var2.setNumberOfTimestepsToBeLogged(3); + EXPECT_EQ(3, var2.numberOfTimestepsToBeLogged()); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp index 9f80fce523c..c4eeefa8d42 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.cpp @@ -106,7 +106,7 @@ namespace detail { } // detail -EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject, std::string actuatedComponentType, std::string actuatedComponentControlType) +EnergyManagementSystemActuator::EnergyManagementSystemActuator(const ModelObject& modelObject, const std::string actuatedComponentType, const std::string actuatedComponentControlType) : ModelObject(EnergyManagementSystemActuator::iddObjectType(), modelObject.model()) { OS_ASSERT(getImpl()); bool ok = setActuatedComponent(modelObject); diff --git a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp index eeadd84169d..7cff1ead70e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemActuator.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemActuator.hpp @@ -43,7 +43,7 @@ class MODEL_API EnergyManagementSystemActuator : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemActuator(const ModelObject& modelObject, std::string actuatedComponentType, std::string actuatedComponentControlType); + explicit EnergyManagementSystemActuator(const ModelObject& modelObject, const std::string actuatedComponentType, const std::string actuatedComponentControlType); virtual ~EnergyManagementSystemActuator() {} diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp index 0305390f375..37b04744a6a 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.cpp @@ -86,7 +86,7 @@ namespace detail { } // detail -EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model, Construction& construction) +EnergyManagementSystemConstructionIndexVariable::EnergyManagementSystemConstructionIndexVariable(const Model& model, const Construction& construction) : ModelObject(EnergyManagementSystemConstructionIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); diff --git a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp index 8d5e4caf345..5ff9c8a4e75 100644 --- a/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemConstructionIndexVariable.hpp @@ -41,7 +41,7 @@ class MODEL_API EnergyManagementSystemConstructionIndexVariable : public ModelOb /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemConstructionIndexVariable(const Model& model, Construction& construction); + explicit EnergyManagementSystemConstructionIndexVariable(const Model& model, const Construction& construction); explicit EnergyManagementSystemConstructionIndexVariable(const Model& model); diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp index b8f7f0df236..9896bcae885 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.cpp @@ -70,30 +70,30 @@ namespace detail { return EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(); } - ModelObject EnergyManagementSystemCurveOrTableIndexVariable_Impl::curveorTableObject() const { - boost::optional value = optionalCurveorTableObject(); + ModelObject EnergyManagementSystemCurveOrTableIndexVariable_Impl::curveOrTableObject() const { + boost::optional value = optionalCurveOrTableObject(); if (!value) { LOG(Info, " does not have an Curveor Table Object attached."); } return value.get(); } - bool EnergyManagementSystemCurveOrTableIndexVariable_Impl::setCurveorTableObject(const ModelObject& allCurves) { + bool EnergyManagementSystemCurveOrTableIndexVariable_Impl::setCurveOrTableObject(const Curve& allCurves) { bool result = setPointer(OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName, allCurves.handle()); return result; } - boost::optional EnergyManagementSystemCurveOrTableIndexVariable_Impl::optionalCurveorTableObject() const { + boost::optional EnergyManagementSystemCurveOrTableIndexVariable_Impl::optionalCurveOrTableObject() const { return getObject().getModelObjectTarget(OS_EnergyManagementSystem_CurveOrTableIndexVariableFields::CurveorTableObjectName); } } // detail -EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, Curve& curve) +EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, const Curve& curve) : ModelObject(EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - bool ok = setCurveorTableObject(curve); + bool ok = setCurveOrTableObject(curve); if (!ok) { remove(); LOG_AND_THROW("Unable to set " << briefDescription() << "'s Curve to " @@ -106,19 +106,19 @@ EnergyManagementSystemCurveOrTableIndexVariable::EnergyManagementSystemCurveOrTa OS_ASSERT(getImpl()); CurveLinear curve = CurveLinear(model); curve.setName("Generic Curve"); - setCurveorTableObject(curve); + setCurveOrTableObject(curve); } IddObjectType EnergyManagementSystemCurveOrTableIndexVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_CurveOrTableIndexVariable); } -ModelObject EnergyManagementSystemCurveOrTableIndexVariable::curveorTableObject() const { - return getImpl()->curveorTableObject(); +ModelObject EnergyManagementSystemCurveOrTableIndexVariable::curveOrTableObject() const { + return getImpl()->curveOrTableObject(); } -bool EnergyManagementSystemCurveOrTableIndexVariable::setCurveorTableObject(const ModelObject& allCurves) { - return getImpl()->setCurveorTableObject(allCurves); +bool EnergyManagementSystemCurveOrTableIndexVariable::setCurveOrTableObject(const Curve& allCurves) { + return getImpl()->setCurveOrTableObject(allCurves); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp index 37aea348d97..fe9b5622280 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable.hpp @@ -22,13 +22,11 @@ #include #include "ModelObject.hpp" -#include "Curve.hpp" namespace openstudio { namespace model { -// TODO: Check the following class names against object getters and setters. -class Curves; +class Curve; namespace detail { @@ -42,7 +40,7 @@ class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable : public ModelOb /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, Curve& curve); //Does Curve cover all object-list AllCurves? + explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model, const Curve& curve); explicit EnergyManagementSystemCurveOrTableIndexVariable(const Model& model); @@ -55,13 +53,13 @@ class MODEL_API EnergyManagementSystemCurveOrTableIndexVariable : public ModelOb /** @name Getters */ //@{ - ModelObject curveorTableObject() const; + ModelObject curveOrTableObject() const; //@} /** @name Setters */ //@{ - bool setCurveorTableObject(const ModelObject& allCurves); + bool setCurveOrTableObject(const Curve& allCurves); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp index cb838719acc..8da710593d2 100644 --- a/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemCurveOrTableIndexVariable_Impl.hpp @@ -26,8 +26,7 @@ namespace openstudio { namespace model { -// TODO: Check the following class names against object getters and setters. -class Curves; +class Curve; namespace detail { @@ -63,13 +62,13 @@ namespace detail { /** @name Getters */ //@{ - ModelObject curveorTableObject() const; + ModelObject curveOrTableObject() const; //@} /** @name Setters */ //@{ - bool setCurveorTableObject(const ModelObject& allCurves); + bool setCurveOrTableObject(const Curve& allCurves); //@} /** @name Other */ @@ -80,7 +79,7 @@ namespace detail { private: REGISTER_LOGGER("openstudio.model.EnergyManagementSystemCurveOrTableIndexVariable"); - boost::optional optionalCurveorTableObject() const; + boost::optional optionalCurveOrTableObject() const; }; } // detail diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp index 6b5393c71bc..386383e7f8c 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.cpp @@ -64,8 +64,12 @@ namespace detail { return EnergyManagementSystemInternalVariable::iddObjectType(); } - boost::optional EnergyManagementSystemInternalVariable_Impl::internalDataIndexKeyName() const { - return getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName,true); + std::string EnergyManagementSystemInternalVariable_Impl::internalDataIndexKeyName() const { + OptionalString result = getString(OS_EnergyManagementSystem_InternalVariableFields::InternalDataIndexKeyName,true); + if (result) { + return result.get(); + } + return ""; } std::string EnergyManagementSystemInternalVariable_Impl::internalDataType() const { @@ -90,7 +94,7 @@ namespace detail { } // detail -EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(const Model& model, std::string internalDataType) +EnergyManagementSystemInternalVariable::EnergyManagementSystemInternalVariable(const Model& model, const std::string internalDataType) : ModelObject(EnergyManagementSystemInternalVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setInternalDataType(internalDataType); @@ -111,7 +115,7 @@ IddObjectType EnergyManagementSystemInternalVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_InternalVariable); } -boost::optional EnergyManagementSystemInternalVariable::internalDataIndexKeyName() const { +std::string EnergyManagementSystemInternalVariable::internalDataIndexKeyName() const { return getImpl()->internalDataIndexKeyName(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp index 1139abb71cc..ffc060df0f5 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable.hpp @@ -42,7 +42,7 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemInternalVariable(const Model& model, std::string internalDataType); + explicit EnergyManagementSystemInternalVariable(const Model& model, const std::string internalDataType); virtual ~EnergyManagementSystemInternalVariable() {} @@ -53,7 +53,7 @@ class MODEL_API EnergyManagementSystemInternalVariable : public ModelObject { /** @name Getters */ //@{ - boost::optional internalDataIndexKeyName() const; + std::string internalDataIndexKeyName() const; std::string internalDataType() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp index 8b1b28a87aa..74cf6eb6299 100644 --- a/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemInternalVariable_Impl.hpp @@ -60,7 +60,7 @@ namespace detail { /** @name Getters */ //@{ - boost::optional internalDataIndexKeyName() const; + std::string internalDataIndexKeyName() const; std::string internalDataType() const; diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp index 72f4840be8c..6952e150324 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.cpp @@ -85,7 +85,7 @@ namespace detail { return EnergyManagementSystemMeteredOutputVariable::iddObjectType(); } - std::string EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableName() const { + std::string EnergyManagementSystemMeteredOutputVariable_Impl::emsVariableName() const { //TODO call emsVAriableObject() return .nameString() boost::optional value = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName,true); return value.get(); @@ -96,14 +96,31 @@ namespace detail { return value.get(); } - boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSProgramorSubroutineName() const { + std::string EnergyManagementSystemMeteredOutputVariable_Impl::emsProgramOrSubroutineName() const { //return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName,true); boost::optional object = getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName); if (object) { return object.get().nameString(); } - boost::optional temp; - return temp; + return ""; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsProgram() const { + boost::optional result; + OptionalWorkspaceObject object = getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName); + if (object) { + result = object->optionalCast(); + } + return result; + } + + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsSubroutine() const { + boost::optional result; + OptionalWorkspaceObject object = getTarget(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName); + if (object) { + result = object->optionalCast(); + } + return result; } std::string EnergyManagementSystemMeteredOutputVariable_Impl::resourceType() const { @@ -121,12 +138,20 @@ namespace detail { return value.get(); } - boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::endUseSubcategory() const { - return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory,true); + std::string EnergyManagementSystemMeteredOutputVariable_Impl::endUseSubcategory() const { + OptionalString results = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseSubcategory,true); + if (results) { + return results.get(); + } + return ""; } - boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::units() const { - return getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units,true); + std::string EnergyManagementSystemMeteredOutputVariable_Impl::units() const { + OptionalString results = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::Units, true); + if (results) { + return results.get(); + } + return ""; } bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { @@ -174,19 +199,18 @@ namespace detail { return result; } - bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, program.handle()); return result; } - bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + bool EnergyManagementSystemMeteredOutputVariable_Impl::setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); return result; } - void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramorSubroutineName() { + void EnergyManagementSystemMeteredOutputVariable_Impl::resetEMSProgramOrSubroutineName() { bool result = setString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, ""); - //bool result = setPointer(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSProgramorSubroutineName, NULL); OS_ASSERT(result); } @@ -225,7 +249,7 @@ namespace detail { OS_ASSERT(result); } - boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::eMSVariableObject() const { + boost::optional EnergyManagementSystemMeteredOutputVariable_Impl::emsVariableObject() const { boost::optional value; boost::optional handle = getString(OS_EnergyManagementSystem_MeteredOutputVariableFields::EMSVariableName, true); if (handle) { @@ -307,7 +331,7 @@ namespace detail { } // detail -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const std::string eMSVariableName) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(eMSVariableName); @@ -321,7 +345,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemActuator& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemActuator& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -336,7 +360,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemSensor& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemSensor& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -351,7 +375,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -366,7 +390,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemTrendVariable& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -381,7 +405,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemInternalVariable& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -396,7 +420,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -411,7 +435,7 @@ EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutput setEndUseCategory("Fans"); } -EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) +EnergyManagementSystemMeteredOutputVariable::EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object) : ModelObject(EnergyManagementSystemMeteredOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -461,16 +485,24 @@ std::vector EnergyManagementSystemMeteredOutputVariable::endUseCate OS_EnergyManagementSystem_MeteredOutputVariableFields::EndUseCategory); } -std::string EnergyManagementSystemMeteredOutputVariable::eMSVariableName() const { - return getImpl()->eMSVariableName(); +std::string EnergyManagementSystemMeteredOutputVariable::emsVariableName() const { + return getImpl()->emsVariableName(); } std::string EnergyManagementSystemMeteredOutputVariable::updateFrequency() const { return getImpl()->updateFrequency(); } -boost::optional EnergyManagementSystemMeteredOutputVariable::eMSProgramorSubroutineName() const { - return getImpl()->eMSProgramorSubroutineName(); +std::string EnergyManagementSystemMeteredOutputVariable::emsProgramOrSubroutineName() const { + return getImpl()->emsProgramOrSubroutineName(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsProgram() const { + return getImpl()->emsProgram(); +} + +boost::optional EnergyManagementSystemMeteredOutputVariable::emsSubroutine() const { + return getImpl()->emsSubroutine(); } std::string EnergyManagementSystemMeteredOutputVariable::resourceType() const { @@ -485,17 +517,17 @@ std::string EnergyManagementSystemMeteredOutputVariable::endUseCategory() const return getImpl()->endUseCategory(); } -boost::optional EnergyManagementSystemMeteredOutputVariable::endUseSubcategory() const { +std::string EnergyManagementSystemMeteredOutputVariable::endUseSubcategory() const { return getImpl()->endUseSubcategory(); } -boost::optional EnergyManagementSystemMeteredOutputVariable::units() const { +std::string EnergyManagementSystemMeteredOutputVariable::units() const { return getImpl()->units(); } -boost::optional EnergyManagementSystemMeteredOutputVariable::eMSVariableObject() const { - return getImpl()->eMSVariableObject(); +boost::optional EnergyManagementSystemMeteredOutputVariable::emsVariableObject() const { + return getImpl()->emsVariableObject(); } boost::optional EnergyManagementSystemMeteredOutputVariable::emsActuator() const { @@ -530,16 +562,16 @@ bool EnergyManagementSystemMeteredOutputVariable::setUpdateFrequency(const std:: return getImpl()->setUpdateFrequency(updateFrequency); } -bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { - return getImpl()->setEMSProgramorSubroutineName(program); +bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program) { + return getImpl()->setEMSProgramOrSubroutineName(program); } -bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { - return getImpl()->setEMSProgramorSubroutineName(subroutine); +bool EnergyManagementSystemMeteredOutputVariable::setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + return getImpl()->setEMSProgramOrSubroutineName(subroutine); } -void EnergyManagementSystemMeteredOutputVariable::resetEMSProgramorSubroutineName() { - getImpl()->resetEMSProgramorSubroutineName(); +void EnergyManagementSystemMeteredOutputVariable::resetEMSProgramOrSubroutineName() { + getImpl()->resetEMSProgramOrSubroutineName(); } bool EnergyManagementSystemMeteredOutputVariable::setResourceType(const std::string& resourceType) { diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp index 025714b0f46..a1cef0b20d0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable.hpp @@ -52,21 +52,21 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const std::string eMSVariableName); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemActuator& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemActuator& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemSensor& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemSensor& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemTrendVariable& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemInternalVariable& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object); - explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + explicit EnergyManagementSystemMeteredOutputVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object); virtual ~EnergyManagementSystemMeteredOutputVariable() {} @@ -85,11 +85,15 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; std::string updateFrequency() const; - boost::optional eMSProgramorSubroutineName() const; + std::string emsProgramOrSubroutineName() const; + + boost::optional emsProgram() const; + + boost::optional emsSubroutine() const; std::string resourceType() const; @@ -97,11 +101,11 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject std::string endUseCategory() const; - boost::optional endUseSubcategory() const; + std::string endUseSubcategory() const; - boost::optional units() const; + std::string units() const; - boost::optional eMSVariableObject() const; + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -119,11 +123,11 @@ class MODEL_API EnergyManagementSystemMeteredOutputVariable : public ModelObject bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine); - void resetEMSProgramorSubroutineName(); + void resetEMSProgramOrSubroutineName(); bool setResourceType(const std::string& resourceType); diff --git a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp index 624d23e100f..ff6118e9b9e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemMeteredOutputVariable_Impl.hpp @@ -62,11 +62,15 @@ namespace detail { /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; std::string updateFrequency() const; - boost::optional eMSProgramorSubroutineName() const; + std::string emsProgramOrSubroutineName() const; + + boost::optional emsProgram() const; + + boost::optional emsSubroutine() const; std::string resourceType() const; @@ -74,11 +78,11 @@ namespace detail { std::string endUseCategory() const; - boost::optional endUseSubcategory() const; + std::string endUseSubcategory() const; - boost::optional units() const; + std::string units() const; - boost::optional eMSVariableObject() const; + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -96,11 +100,11 @@ namespace detail { bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine); - void resetEMSProgramorSubroutineName(); + void resetEMSProgramOrSubroutineName(); bool setResourceType(const std::string& resourceType); diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp index c81024b9ab6..b81c55676c7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.cpp @@ -85,12 +85,12 @@ namespace detail { return EnergyManagementSystemOutputVariable::iddObjectType(); } - std::string EnergyManagementSystemOutputVariable_Impl::eMSVariableName() const { + std::string EnergyManagementSystemOutputVariable_Impl::emsVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName,true); return value.get(); } - std::string EnergyManagementSystemOutputVariable_Impl::typeofDatainVariable() const { + std::string EnergyManagementSystemOutputVariable_Impl::typeOfDataInVariable() const { boost::optional value = getString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable,true); return value.get(); } @@ -100,18 +100,39 @@ namespace detail { return value.get(); } - boost::optional EnergyManagementSystemOutputVariable_Impl::eMSProgramorSubroutineName() const { + std::string EnergyManagementSystemOutputVariable_Impl::emsProgramOrSubroutineName() const { //return getString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName,true); boost::optional object = getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName); if (object) { return object.get().nameString(); } - boost::optional temp; - return temp; + return ""; } - boost::optional EnergyManagementSystemOutputVariable_Impl::units() const { - return getString(OS_EnergyManagementSystem_OutputVariableFields::Units,true); + boost::optional EnergyManagementSystemOutputVariable_Impl::emsProgram() const { + boost::optional result; + OptionalWorkspaceObject object = getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName); + if (object) { + result = object->optionalCast(); + } + return result; + } + + boost::optional EnergyManagementSystemOutputVariable_Impl::emsSubroutine() const { + boost::optional result; + OptionalWorkspaceObject object = getTarget(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName); + if (object) { + result = object->optionalCast(); + } + return result; + } + + std::string EnergyManagementSystemOutputVariable_Impl::units() const { + OptionalString results = getString(OS_EnergyManagementSystem_OutputVariableFields::Units,true); + if (results) { + return results.get(); + } + return ""; } bool EnergyManagementSystemOutputVariable_Impl::setEMSVariableName(const std::string& eMSVariableName) { @@ -154,7 +175,7 @@ namespace detail { return result; } - bool EnergyManagementSystemOutputVariable_Impl::setTypeofDatainVariable(const std::string& typeofDatainVariable) { + bool EnergyManagementSystemOutputVariable_Impl::setTypeOfDataInVariable(const std::string& typeofDatainVariable) { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable, typeofDatainVariable); return result; } @@ -164,17 +185,17 @@ namespace detail { return result; } - bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { + bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program) { bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, program.handle()); return result; } - bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + bool EnergyManagementSystemOutputVariable_Impl::setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, subroutine.handle()); return result; } - void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramorSubroutineName() { + void EnergyManagementSystemOutputVariable_Impl::resetEMSProgramOrSubroutineName() { bool result = setString(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, ""); //bool result = setPointer(OS_EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName, NULL); OS_ASSERT(result); @@ -190,7 +211,7 @@ namespace detail { OS_ASSERT(result); } - boost::optional EnergyManagementSystemOutputVariable_Impl::eMSVariableObject() const { + boost::optional EnergyManagementSystemOutputVariable_Impl::emsVariableObject() const { boost::optional value; boost::optional handle = getString(OS_EnergyManagementSystem_OutputVariableFields::EMSVariableName, true); if (handle) { @@ -272,7 +293,7 @@ namespace detail { } // detail -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const std::string eMSVariableName) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(eMSVariableName); @@ -281,10 +302,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << eMSVariableName << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemActuator& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemActuator& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -294,10 +315,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemSensor& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemSensor& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -307,10 +328,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -320,10 +341,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemTrendVariable& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -333,10 +354,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemInternalVariable& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -346,10 +367,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -359,10 +380,10 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } -EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) +EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object) : ModelObject(EnergyManagementSystemOutputVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -372,7 +393,7 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const << object.briefDescription() << "."); } setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const Model& model) @@ -381,14 +402,14 @@ EnergyManagementSystemOutputVariable::EnergyManagementSystemOutputVariable(const OS_ASSERT(getImpl()); //TODO setEMSVariableName to a valid default setUpdateFrequency("ZoneTimestep"); - setTypeofDatainVariable("Averaged"); + setTypeOfDataInVariable("Averaged"); } IddObjectType EnergyManagementSystemOutputVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_OutputVariable); } -std::vector EnergyManagementSystemOutputVariable::typeofDatainVariableValues() { +std::vector EnergyManagementSystemOutputVariable::typeOfDataInVariableValues() { return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable); } @@ -398,28 +419,36 @@ std::vector EnergyManagementSystemOutputVariable::updateFrequencyVa OS_EnergyManagementSystem_OutputVariableFields::UpdateFrequency); } -std::string EnergyManagementSystemOutputVariable::eMSVariableName() const { - return getImpl()->eMSVariableName(); +std::string EnergyManagementSystemOutputVariable::emsVariableName() const { + return getImpl()->emsVariableName(); } -std::string EnergyManagementSystemOutputVariable::typeofDatainVariable() const { - return getImpl()->typeofDatainVariable(); +std::string EnergyManagementSystemOutputVariable::typeOfDataInVariable() const { + return getImpl()->typeOfDataInVariable(); } std::string EnergyManagementSystemOutputVariable::updateFrequency() const { return getImpl()->updateFrequency(); } -boost::optional EnergyManagementSystemOutputVariable::eMSProgramorSubroutineName() const { - return getImpl()->eMSProgramorSubroutineName(); +std::string EnergyManagementSystemOutputVariable::emsProgramOrSubroutineName() const { + return getImpl()->emsProgramOrSubroutineName(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsProgram() const { + return getImpl()->emsProgram(); +} + +boost::optional EnergyManagementSystemOutputVariable::emsSubroutine() const { + return getImpl()->emsSubroutine(); } -boost::optional EnergyManagementSystemOutputVariable::units() const { +std::string EnergyManagementSystemOutputVariable::units() const { return getImpl()->units(); } -boost::optional EnergyManagementSystemOutputVariable::eMSVariableObject() const { - return getImpl()->eMSVariableObject(); +boost::optional EnergyManagementSystemOutputVariable::emsVariableObject() const { + return getImpl()->emsVariableObject(); } boost::optional EnergyManagementSystemOutputVariable::emsActuator() const { @@ -450,24 +479,24 @@ boost::optional EnergyManagemen return getImpl()->emsConstructionIndexVariable(); } -bool EnergyManagementSystemOutputVariable::setTypeofDatainVariable(const std::string& typeofDatainVariable) { - return getImpl()->setTypeofDatainVariable(typeofDatainVariable); +bool EnergyManagementSystemOutputVariable::setTypeOfDataInVariable(const std::string& typeofDatainVariable) { + return getImpl()->setTypeOfDataInVariable(typeofDatainVariable); } bool EnergyManagementSystemOutputVariable::setUpdateFrequency(const std::string& updateFrequency) { return getImpl()->setUpdateFrequency(updateFrequency); } -bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program) { - return getImpl()->setEMSProgramorSubroutineName(program); +bool EnergyManagementSystemOutputVariable::setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program) { + return getImpl()->setEMSProgramOrSubroutineName(program); } -bool EnergyManagementSystemOutputVariable::setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { - return getImpl()->setEMSProgramorSubroutineName(subroutine); +bool EnergyManagementSystemOutputVariable::setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine) { + return getImpl()->setEMSProgramOrSubroutineName(subroutine); } -void EnergyManagementSystemOutputVariable::resetEMSProgramorSubroutineName() { - getImpl()->resetEMSProgramorSubroutineName(); +void EnergyManagementSystemOutputVariable::resetEMSProgramOrSubroutineName() { + getImpl()->resetEMSProgramOrSubroutineName(); } bool EnergyManagementSystemOutputVariable::setUnits(const std::string& units) { diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp index 409d65a9ce9..3dafef18e72 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable.hpp @@ -51,21 +51,21 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemOutputVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemOutputVariable(const Model& model, const std::string eMSVariableName); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemActuator& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemActuator& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemSensor& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemSensor& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemTrendVariable& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemInternalVariable& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object); - explicit EnergyManagementSystemOutputVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + explicit EnergyManagementSystemOutputVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object); virtual ~EnergyManagementSystemOutputVariable() {} @@ -73,28 +73,28 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { static IddObjectType iddObjectType(); - static std::vector typeofDatainVariableValues(); + static std::vector typeOfDataInVariableValues(); static std::vector updateFrequencyValues(); /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; - std::string typeofDatainVariable() const; + std::string typeOfDataInVariable() const; std::string updateFrequency() const; - boost::optional eMSProgramorSubroutineName() const; - //TODO - //boost::optional eMSProgram() const; + std::string emsProgramOrSubroutineName() const; - //boost::optional eMSSubroutine() const; + boost::optional emsProgram() const; - boost::optional units() const; + boost::optional emsSubroutine() const; - boost::optional eMSVariableObject() const; + std::string units() const; + + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -110,15 +110,15 @@ class MODEL_API EnergyManagementSystemOutputVariable : public ModelObject { bool setEMSVariableName(const std::string& eMSVariableName); - bool setTypeofDatainVariable(const std::string& typeofDatainVariable); + bool setTypeOfDataInVariable(const std::string& typeofDatainVariable); bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine); - void resetEMSProgramorSubroutineName(); + void resetEMSProgramOrSubroutineName(); bool setUnits(const std::string& units); diff --git a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp index c4100037de7..69df3d9d466 100644 --- a/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemOutputVariable_Impl.hpp @@ -60,17 +60,21 @@ namespace detail { /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; - std::string typeofDatainVariable() const; + std::string typeOfDataInVariable() const; std::string updateFrequency() const; - boost::optional eMSProgramorSubroutineName() const; + std::string emsProgramOrSubroutineName() const; - boost::optional units() const; + boost::optional emsProgram() const; - boost::optional eMSVariableObject() const; + boost::optional emsSubroutine() const; + + std::string units() const; + + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -87,15 +91,15 @@ namespace detail { bool setEMSVariableName(const std::string& eMSVariableName); - bool setTypeofDatainVariable(const std::string& typeofDatainVariable); + bool setTypeOfDataInVariable(const std::string& typeofDatainVariable); bool setUpdateFrequency(const std::string& updateFrequency); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemProgram& program); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemProgram& program); - bool setEMSProgramorSubroutineName(const EnergyManagementSystemSubroutine& subroutine); + bool setEMSProgramOrSubroutineName(const EnergyManagementSystemSubroutine& subroutine); - void resetEMSProgramorSubroutineName(); + void resetEMSProgramOrSubroutineName(); bool setUnits(const std::string& units); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp index e6e6508bfe1..5516e099596 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.cpp @@ -74,7 +74,7 @@ namespace detail { return EnergyManagementSystemProgram::iddObjectType(); } - boost::optional EnergyManagementSystemProgram_Impl::body() const { + std::string EnergyManagementSystemProgram_Impl::body() const { //return program body as string // loop through extensible groups and add ProgramLine to body string. @@ -113,7 +113,7 @@ namespace detail { }; //clobber existing body - this->eraseBody(); + this->resetBody(); // remove '\r' from the body string std::string body_minus_r = body; @@ -129,7 +129,6 @@ namespace detail { std::string comment; //add program lines to body - std::vector ok(body_minus_nl.size(), false); for (size_t i = 0; i < body_minus_nl.size(); i++) { //split string on comment character ! comments = splitString(body_minus_nl.at(i), '!'); @@ -148,6 +147,9 @@ namespace detail { } //insert program line result = group.setString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, comments[0]); + if (!result) { + return result; + } //check if comments exist if (comments.size() > 1) { //clear out the old comment @@ -165,19 +167,11 @@ namespace detail { } else { result = false; } - ok.at(i) = result; - } - //check if all the programs set true - result = true; - for (size_t i = 0; i > result; @@ -244,7 +238,7 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemProgram_Impl::lines() const { + std::vector EnergyManagementSystemProgram_Impl::lines() const { //return vector of lines from body std::vector result; boost::optional comment; @@ -290,20 +284,14 @@ namespace detail { }; //clobber existing body - this->eraseBody(); + this->resetBody(); //add program lines to body - std::vector ok(lines.size(), false); for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - ok.at(i) = result; - } - //check if all the programs set true - result = true; - for (size_t i = 0; i EnergyManagementSystemProgram::body() const { +std::string EnergyManagementSystemProgram::body() const { return getImpl()->body(); } @@ -390,15 +378,15 @@ bool EnergyManagementSystemProgram::setBody(const std::string& body) { return getImpl()->setBody(body); } -bool EnergyManagementSystemProgram::eraseBody() { - return getImpl()->eraseBody(); +bool EnergyManagementSystemProgram::resetBody() { + return getImpl()->resetBody(); } bool EnergyManagementSystemProgram::addLine(const std::string& line) { return getImpl()->addLine(line); } -boost::optional> EnergyManagementSystemProgram::lines() const { +std::vector EnergyManagementSystemProgram::lines() const { return getImpl()->lines(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp index 95d1e031e66..346566fbdf4 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram.hpp @@ -49,9 +49,9 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { /** @name Getters */ //@{ - boost::optional body() const; + std::string body() const; - boost::optional> lines() const; + std::vector lines() const; std::vector referencedObjects() const; @@ -63,7 +63,7 @@ class MODEL_API EnergyManagementSystemProgram : public ModelObject { bool setBody(const std::string& body); - bool eraseBody(); + bool resetBody(); bool addLine(const std::string& body); diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp index 171c8b0b1e3..d48d3d67ed0 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.cpp @@ -69,8 +69,12 @@ namespace detail { return EnergyManagementSystemProgramCallingManager::iddObjectType(); } - boost::optional EnergyManagementSystemProgramCallingManager_Impl::callingPoint() const { - return getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint,true); + std::string EnergyManagementSystemProgramCallingManager_Impl::callingPoint() const { + OptionalString results = getString(OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint,true); + if (results) { + return results.get(); + } + return ""; } bool EnergyManagementSystemProgramCallingManager_Impl::setCallingPoint(const std::string& callingPoint) { @@ -170,36 +174,6 @@ namespace detail { return result; } - std::vector EnergyManagementSystemProgramCallingManager_Impl::nullPrograms() const { - //return vector of indices of null programs in the program vector - std::vector result; - unsigned i = 0; - auto groups = extensibleGroups(); - unsigned sizeOfGroup = numExtensibleGroups(); - for (auto &group : groups) { - if (group.empty()) { - result.push_back(i); - }; - i++; - } - return result; - } - - bool EnergyManagementSystemProgramCallingManager_Impl::removeNullPrograms() { - //remove any null entries in the vector of programs - bool result = false; - std::vector nullProgs; - nullProgs = this->nullPrograms(); - - if (!nullProgs.empty()) { - int j = 0; - for (size_t i = 0; i < nullProgs.size(); i++) { - result = this->eraseProgram(j); - j++; - }; - }; - return result; - } } // detail EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(const Model& model) @@ -218,7 +192,7 @@ std::vector EnergyManagementSystemProgramCallingManager::validCalli OS_EnergyManagementSystem_ProgramCallingManagerFields::EnergyPlusModelCallingPoint); } -boost::optional EnergyManagementSystemProgramCallingManager::callingPoint() const { +std::string EnergyManagementSystemProgramCallingManager::callingPoint() const { return getImpl()->callingPoint(); } @@ -254,14 +228,6 @@ bool EnergyManagementSystemProgramCallingManager::setPrograms(const std::vector< return getImpl()->setPrograms(programs); } -std::vector EnergyManagementSystemProgramCallingManager::nullPrograms() const { - return getImpl()->nullPrograms(); -} - -bool EnergyManagementSystemProgramCallingManager::removeNullPrograms() { - return getImpl()->removeNullPrograms(); -} - /// @cond EnergyManagementSystemProgramCallingManager::EnergyManagementSystemProgramCallingManager(std::shared_ptr impl) : ModelObject(impl) diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp index cf46c12669a..b5c6cc3753e 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager.hpp @@ -52,14 +52,12 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject /** @name Getters */ //@{ - boost::optional callingPoint() const; + std::string callingPoint() const; std::vector programs() const; boost::optional getProgram(unsigned index) const; - std::vector nullPrograms() const; - //@} /** @name Setters */ //@{ @@ -76,7 +74,6 @@ class MODEL_API EnergyManagementSystemProgramCallingManager : public ModelObject bool setPrograms(const std::vector& programs); - bool removeNullPrograms(); //@} /** @name Other */ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp index 8bf70abfdeb..77acac03f35 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgramCallingManager_Impl.hpp @@ -61,14 +61,12 @@ namespace detail { /** @name Getters */ //@{ - boost::optional callingPoint() const; + std::string callingPoint() const; std::vector programs() const; boost::optional getProgram(unsigned index) const; - std::vector nullPrograms() const; - //@} /** @name Setters */ //@{ @@ -85,8 +83,6 @@ namespace detail { bool setPrograms(const std::vector& programs); - bool removeNullPrograms(); - //@} /** @name Other */ //@{ diff --git a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp index 1fa6e24585b..d780dde443b 100644 --- a/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemProgram_Impl.hpp @@ -60,9 +60,9 @@ namespace detail { /** @name Getters */ //@{ - boost::optional body() const; + std::string body() const; - boost::optional> lines() const; + std::vector lines() const; std::vector referencedObjects() const; @@ -75,7 +75,7 @@ namespace detail { bool setBody(const std::string& body); - bool eraseBody(); + bool resetBody(); bool addLine(const std::string& body); diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp index 5a5ba8c38f2..39064e0cb29 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.cpp @@ -72,8 +72,12 @@ namespace detail { return EnergyManagementSystemSensor::iddObjectType(); } - boost::optional EnergyManagementSystemSensor_Impl::keyName() const { - return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, true); + std::string EnergyManagementSystemSensor_Impl::keyName() const { + OptionalString results = getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterIndexKeyName, true); + if (results) { + return results.get(); + } + return ""; } boost::optional EnergyManagementSystemSensor_Impl::outputVariable() const { @@ -94,8 +98,12 @@ namespace detail { return value.get(); } - boost::optional EnergyManagementSystemSensor_Impl::outputVariableOrMeterName() const { - return getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, true); + std::string EnergyManagementSystemSensor_Impl::outputVariableOrMeterName() const { + OptionalString results = getString(OS_EnergyManagementSystem_SensorFields::OutputVariableorOutputMeterName, true); + if (results) { + return results.get(); + } + return ""; } bool EnergyManagementSystemSensor_Impl::setKeyName(const std::string& keyName) { @@ -159,7 +167,7 @@ namespace detail { } // detail -EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, OutputVariable& outvar) +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, const OutputVariable& outvar) : ModelObject(EnergyManagementSystemSensor::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setOutputVariable(outvar); @@ -170,7 +178,7 @@ EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, O } } -EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar) +EnergyManagementSystemSensor::EnergyManagementSystemSensor(const Model& model, const OutputMeter& outvar) : ModelObject(EnergyManagementSystemSensor::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setOutputMeter(outvar); @@ -203,7 +211,7 @@ IddObjectType EnergyManagementSystemSensor::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_Sensor); } -boost::optional EnergyManagementSystemSensor::keyName() const { +std::string EnergyManagementSystemSensor::keyName() const { return getImpl()->keyName(); } @@ -215,7 +223,7 @@ boost::optional EnergyManagementSystemSensor::outputMeter() const { return getImpl()->outputMeter(); } -boost::optional EnergyManagementSystemSensor::outputVariableOrMeterName() const { +std::string EnergyManagementSystemSensor::outputVariableOrMeterName() const { return getImpl()->outputVariableOrMeterName(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp index db80dff263e..afe4439a1ea 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor.hpp @@ -50,9 +50,9 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemSensor(const Model& model, OutputVariable& outvar); + explicit EnergyManagementSystemSensor(const Model& model, const OutputVariable& outvar); - explicit EnergyManagementSystemSensor(const Model& model, OutputMeter& outvar); + explicit EnergyManagementSystemSensor(const Model& model, const OutputMeter& outvar); explicit EnergyManagementSystemSensor(const Model& model, const std::string& outputVariableOrMeterName); @@ -65,11 +65,11 @@ class MODEL_API EnergyManagementSystemSensor : public ModelObject { /** @name Getters */ //@{ - boost::optional keyName() const; + std::string keyName() const; boost::optional outputVariable() const; boost::optional outputMeter() const; - boost::optional outputVariableOrMeterName() const; + std::string outputVariableOrMeterName() const; //@} /** @name Setters */ diff --git a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp index 82f5deabffa..d54a9d3a47f 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSensor_Impl.hpp @@ -67,11 +67,11 @@ namespace detail { /** @name Getters */ //@{ - boost::optional keyName() const; + std::string keyName() const; boost::optional outputVariable() const; boost::optional outputMeter() const; - boost::optional outputVariableOrMeterName() const; + std::string outputVariableOrMeterName() const; //@} /** @name Setters */ diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp index 0f97b7e8150..808840f9051 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.cpp @@ -71,7 +71,7 @@ namespace detail { return EnergyManagementSystemSubroutine::iddObjectType(); } - boost::optional EnergyManagementSystemSubroutine_Impl::body() const { + std::string EnergyManagementSystemSubroutine_Impl::body() const { //return program body as string // loop through extensible groups and add ProgramLine to body string. @@ -110,7 +110,7 @@ namespace detail { }; //clobber existing body - this->eraseBody(); + this->resetBody(); // remove '\r' from the body string std::string body_minus_r = body; @@ -126,7 +126,6 @@ namespace detail { std::string comment; //add program lines to body - std::vector ok(body_minus_nl.size(), false); for (size_t i = 0; i < body_minus_nl.size(); i++) { //split string on comment character ! comments = splitString(body_minus_nl.at(i), '!'); @@ -145,6 +144,9 @@ namespace detail { } //insert program line result = group.setString(OS_EnergyManagementSystem_SubroutineExtensibleFields::ProgramLine, comments[0]); + if (!result) { + return result; + } //check if comments exist if (comments.size() > 1) { //clear out the old comment @@ -162,19 +164,11 @@ namespace detail { } else { result = false; } - ok.at(i) = result; - } - //check if all the programs set true - result = true; - for (size_t i = 0; i > result; @@ -240,7 +234,7 @@ namespace detail { return result; } - boost::optional> EnergyManagementSystemSubroutine_Impl::lines() const { + std::vector EnergyManagementSystemSubroutine_Impl::lines() const { //return vector of lines from body std::vector result; boost::optional comment; @@ -286,20 +280,14 @@ namespace detail { }; //clobber existing body - this->eraseBody(); + this->resetBody(); //add program lines to body - std::vector ok(lines.size(), false); for (size_t i = 0; i < lines.size(); i++) { //use method addLine to add each line result = addLine(lines.at(i)); - ok.at(i) = result; - } - //check if all the programs set true - result = true; - for (size_t i = 0; i EnergyManagementSystemSubroutine::body() const { +std::string EnergyManagementSystemSubroutine::body() const { return getImpl()->body(); } @@ -391,15 +379,15 @@ bool EnergyManagementSystemSubroutine::setBody(const std::string& body) { return getImpl()->setBody(body); } -bool EnergyManagementSystemSubroutine::eraseBody() { - return getImpl()->eraseBody(); +bool EnergyManagementSystemSubroutine::resetBody() { + return getImpl()->resetBody(); } bool EnergyManagementSystemSubroutine::addLine(const std::string& line) { return getImpl()->addLine(line); } -boost::optional> EnergyManagementSystemSubroutine::lines() const { +std::vector EnergyManagementSystemSubroutine::lines() const { return getImpl()->lines(); } diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp index 6723a721fe6..e6fe06963c7 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine.hpp @@ -49,9 +49,9 @@ class MODEL_API EnergyManagementSystemSubroutine : public ModelObject { /** @name Getters */ //@{ - boost::optional body() const; + std::string body() const; - boost::optional> lines() const; + std::vector lines() const; std::vector referencedObjects() const; @@ -63,7 +63,7 @@ class MODEL_API EnergyManagementSystemSubroutine : public ModelObject { bool setBody(const std::string& body); - bool eraseBody(); + bool resetBody(); bool addLine(const std::string& body); diff --git a/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp index c205aa9079e..2cc09950483 100644 --- a/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemSubroutine_Impl.hpp @@ -60,9 +60,9 @@ namespace detail { /** @name Getters */ //@{ - boost::optional body() const; + std::string body() const; - boost::optional> lines() const; + std::vector lines() const; std::vector referencedObjects() const; @@ -74,7 +74,7 @@ namespace detail { bool setBody(const std::string& body); - bool eraseBody(); + bool resetBody(); bool addLine(const std::string& body); diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp index d70c9064bce..9b3b4ef4b34 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.cpp @@ -78,12 +78,12 @@ namespace detail { return EnergyManagementSystemTrendVariable::iddObjectType(); } - std::string EnergyManagementSystemTrendVariable_Impl::eMSVariableName() const { + std::string EnergyManagementSystemTrendVariable_Impl::emsVariableName() const { boost::optional value = getString(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName,true); return value.get(); } - boost::optional EnergyManagementSystemTrendVariable_Impl::eMSVariableObject() const { + boost::optional EnergyManagementSystemTrendVariable_Impl::emsVariableObject() const { boost::optional value = this->getTarget(OS_EnergyManagementSystem_TrendVariableFields::EMSVariableName)->cast(); return value; } @@ -122,7 +122,7 @@ namespace detail { return value; } - int EnergyManagementSystemTrendVariable_Impl::numberofTimestepstobeLogged() const { + int EnergyManagementSystemTrendVariable_Impl::numberOfTimestepsToBeLogged() const { boost::optional value = getInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged,true); return value.get(); } @@ -168,14 +168,14 @@ namespace detail { return result; } - bool EnergyManagementSystemTrendVariable_Impl::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { + bool EnergyManagementSystemTrendVariable_Impl::setNumberOfTimestepsToBeLogged(int numberofTimestepstobeLogged) { bool result = setInt(OS_EnergyManagementSystem_TrendVariableFields::NumberofTimestepstobeLogged, numberofTimestepstobeLogged); return result; } } // detail -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const std::string eMSVariableName) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(eMSVariableName); @@ -183,10 +183,10 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M remove(); LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << eMSVariableName << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemActuator& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemActuator& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -195,10 +195,10 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemSensor& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemSensor& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -207,9 +207,9 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemGlobalVariable& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -218,9 +218,9 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemTrendVariable& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemTrendVariable& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -229,9 +229,9 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemInternalVariable& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemInternalVariable& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -240,9 +240,9 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -251,9 +251,9 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } -EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object) +EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(), model) { OS_ASSERT(getImpl()); bool ok = setEMSVariableName(object); @@ -262,22 +262,22 @@ EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const M LOG_AND_THROW("Unable to set " << briefDescription() << "'s eMSVariableName to " << object.briefDescription() << "."); } - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } EnergyManagementSystemTrendVariable::EnergyManagementSystemTrendVariable(const Model& model) : ModelObject(EnergyManagementSystemTrendVariable::iddObjectType(),model) { OS_ASSERT(getImpl()); - setNumberofTimestepstobeLogged(1); + setNumberOfTimestepsToBeLogged(1); } IddObjectType EnergyManagementSystemTrendVariable::iddObjectType() { return IddObjectType(IddObjectType::OS_EnergyManagementSystem_TrendVariable); } -std::string EnergyManagementSystemTrendVariable::eMSVariableName() const { - return getImpl()->eMSVariableName(); +std::string EnergyManagementSystemTrendVariable::emsVariableName() const { + return getImpl()->emsVariableName(); } boost::optional EnergyManagementSystemTrendVariable::emsActuator() const { @@ -308,12 +308,12 @@ boost::optional EnergyManagemen return getImpl()->emsConstructionIndexVariable(); } -boost::optional EnergyManagementSystemTrendVariable::eMSVariableObject() const { - return getImpl()->eMSVariableObject(); +boost::optional EnergyManagementSystemTrendVariable::emsVariableObject() const { + return getImpl()->emsVariableObject(); } -int EnergyManagementSystemTrendVariable::numberofTimestepstobeLogged() const { - return getImpl()->numberofTimestepstobeLogged(); +int EnergyManagementSystemTrendVariable::numberOfTimestepsToBeLogged() const { + return getImpl()->numberOfTimestepsToBeLogged(); } bool EnergyManagementSystemTrendVariable::setEMSVariableName(const std::string& eMSVariableName) { @@ -349,8 +349,8 @@ bool EnergyManagementSystemTrendVariable::setEMSVariableName(const EnergyManagem return getImpl()->setEMSVariableName(object); } -bool EnergyManagementSystemTrendVariable::setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged) { - return getImpl()->setNumberofTimestepstobeLogged(numberofTimestepstobeLogged); +bool EnergyManagementSystemTrendVariable::setNumberOfTimestepsToBeLogged(int numberofTimestepstobeLogged) { + return getImpl()->setNumberOfTimestepsToBeLogged(numberofTimestepstobeLogged); } /// @cond diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp index 2d6828f1f01..b3e68ed9d46 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable.hpp @@ -49,21 +49,21 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { public: /** @name Constructors and Destructors */ //@{ - explicit EnergyManagementSystemTrendVariable(const Model& model, std::string eMSVariableName); + explicit EnergyManagementSystemTrendVariable(const Model& model, const std::string eMSVariableName); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemActuator& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemActuator& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemSensor& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemSensor& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemGlobalVariable& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemGlobalVariable& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemTrendVariable& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemTrendVariable& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemInternalVariable& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemInternalVariable& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemCurveOrTableIndexVariable& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemCurveOrTableIndexVariable& object); - explicit EnergyManagementSystemTrendVariable(const Model& model, EnergyManagementSystemConstructionIndexVariable& object); + explicit EnergyManagementSystemTrendVariable(const Model& model, const EnergyManagementSystemConstructionIndexVariable& object); virtual ~EnergyManagementSystemTrendVariable() {} @@ -74,11 +74,11 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; - int numberofTimestepstobeLogged() const; + int numberOfTimestepsToBeLogged() const; - boost::optional eMSVariableObject() const; + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -94,7 +94,7 @@ class MODEL_API EnergyManagementSystemTrendVariable : public ModelObject { bool setEMSVariableName(const std::string& eMSVariableName); - bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + bool setNumberOfTimestepsToBeLogged(int numberofTimestepstobeLogged); bool setEMSVariableName(const EnergyManagementSystemActuator& object); bool setEMSVariableName(const EnergyManagementSystemSensor& object); diff --git a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp index 1aed80ceddc..b6937424964 100644 --- a/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp +++ b/openstudiocore/src/model/EnergyManagementSystemTrendVariable_Impl.hpp @@ -60,11 +60,11 @@ namespace detail { /** @name Getters */ //@{ - std::string eMSVariableName() const; + std::string emsVariableName() const; - int numberofTimestepstobeLogged() const; + int numberOfTimestepsToBeLogged() const; - boost::optional eMSVariableObject() const; + boost::optional emsVariableObject() const; boost::optional emsActuator() const; boost::optional emsSensor() const; @@ -80,7 +80,7 @@ namespace detail { bool setEMSVariableName(const std::string& eMSVariableName); - bool setNumberofTimestepstobeLogged(int numberofTimestepstobeLogged); + bool setNumberOfTimestepsToBeLogged(int numberofTimestepstobeLogged); bool setEMSVariableName(const EnergyManagementSystemActuator& object); bool setEMSVariableName(const EnergyManagementSystemSensor& object); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp index 0171f088d7b..a8caf1d96d2 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemCurveOrTableIndexVariable_GTest.cpp @@ -42,6 +42,6 @@ TEST_F(ModelFixture, EMS_CurveOrTableIndexVariable) EnergyManagementSystemCurveOrTableIndexVariable emsCurve(model, c1); //emsCurve.setCurveorTableObject(c1); - EXPECT_EQ(c1.handle(), emsCurve.curveorTableObject().handle()); + EXPECT_EQ(c1.handle(), emsCurve.curveOrTableObject().handle()); model.save(toPath("./EMS_curvetest.osm"), true); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp index 0d93a5b0257..0b18f2241b1 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemInternalVariable_GTest.cpp @@ -41,9 +41,9 @@ TEST_F(ModelFixture, EMSInternalVariable_EMSInternalVariable) // add internal variable EnergyManagementSystemInternalVariable var(model, "TestName"); var.setInternalDataIndexKeyName("TestName"); - EXPECT_EQ("TestName", var.internalDataIndexKeyName().get()); + EXPECT_EQ("TestName", var.internalDataIndexKeyName()); var.resetInternalDataIndexKeyName(); - EXPECT_EQ("", var.internalDataIndexKeyName().get()); + EXPECT_EQ("", var.internalDataIndexKeyName()); //var.setInternalDataType("TestName"); EXPECT_EQ("TestName", var.internalDataType()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp index 56ceafe9dec..6a201bc8bde 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemMeteredOutputVariable_GTest.cpp @@ -62,15 +62,17 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) EnergyManagementSystemMeteredOutputVariable meteredoutvar(model, OATdbSensor.name().get()); //meteredoutvar.setEMSVariableName(OATdbSensor.name().get()); - EXPECT_EQ(meteredoutvar.eMSVariableName(), OATdbSensor.name().get()); + EXPECT_EQ(meteredoutvar.emsVariableName(), OATdbSensor.name().get()); meteredoutvar.setUpdateFrequency("ZoneTimestep"); EXPECT_EQ("ZoneTimestep",meteredoutvar.updateFrequency()); - meteredoutvar.setEMSProgramorSubroutineName(program_1); - EXPECT_EQ(program_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); - meteredoutvar.resetEMSProgramorSubroutineName(); - EXPECT_FALSE(meteredoutvar.eMSProgramorSubroutineName()); - meteredoutvar.setEMSProgramorSubroutineName(subroutine_1); - EXPECT_EQ(subroutine_1.name().get(), meteredoutvar.eMSProgramorSubroutineName().get()); + meteredoutvar.setEMSProgramOrSubroutineName(program_1); + EXPECT_EQ(program_1.name().get(), meteredoutvar.emsProgramOrSubroutineName()); + EXPECT_EQ(program_1, meteredoutvar.emsProgram()); + meteredoutvar.resetEMSProgramOrSubroutineName(); + EXPECT_EQ("",meteredoutvar.emsProgramOrSubroutineName()); + meteredoutvar.setEMSProgramOrSubroutineName(subroutine_1); + EXPECT_EQ(subroutine_1.name().get(), meteredoutvar.emsProgramOrSubroutineName()); + EXPECT_EQ(subroutine_1, meteredoutvar.emsSubroutine()); meteredoutvar.setResourceType("NaturalGas"); EXPECT_EQ("NaturalGas", meteredoutvar.resourceType()); meteredoutvar.setGroupType("HVAC"); @@ -78,7 +80,7 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) meteredoutvar.setEndUseCategory("Heating"); EXPECT_EQ("Heating", meteredoutvar.endUseCategory()); meteredoutvar.setEndUseSubcategory("Madeup"); - EXPECT_EQ("Madeup", meteredoutvar.endUseSubcategory().get()); + EXPECT_EQ("Madeup", meteredoutvar.endUseSubcategory()); model.save(toPath("./EMS_meteredoutvar.osm"), true); @@ -88,8 +90,8 @@ TEST_F(ModelFixture, EMSMeteredOutputVariable) outvar_sen.setName("outputVar sen"); EXPECT_EQ("outputVar sen", outvar_sen.nameString()); - ASSERT_TRUE(outvar_sen.eMSVariableObject()); + ASSERT_TRUE(outvar_sen.emsVariableObject()); ASSERT_TRUE(outvar_sen.emsSensor()); - EXPECT_EQ(outvar_sen.eMSVariableObject().get(), outvar_sen.emsSensor().get()); + EXPECT_EQ(outvar_sen.emsVariableObject().get(), outvar_sen.emsSensor().get()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp index bf20e55e586..57ad0480ecc 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemOutputVariable_GTest.cpp @@ -106,15 +106,14 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) outvar.setUpdateFrequency("SystemTimestep"); EXPECT_EQ("SystemTimestep", outvar.updateFrequency()); //type of data in variable - update = outvar.setTypeofDatainVariable("BadValue"); + update = outvar.setTypeOfDataInVariable("BadValue"); EXPECT_EQ(false, update); - outvar.setTypeofDatainVariable("Averaged"); - EXPECT_EQ("Averaged", outvar.typeofDatainVariable()); - outvar.setTypeofDatainVariable("Summed"); - EXPECT_EQ("Summed", outvar.typeofDatainVariable()); + outvar.setTypeOfDataInVariable("Averaged"); + EXPECT_EQ("Averaged", outvar.typeOfDataInVariable()); + outvar.setTypeOfDataInVariable("Summed"); + EXPECT_EQ("Summed", outvar.typeOfDataInVariable()); //program or subroutine name - bool init = outvar.eMSProgramorSubroutineName().is_initialized(); - EXPECT_EQ(false, init); + EXPECT_EQ("", outvar.emsProgramOrSubroutineName()); //bool setprogram = outvar.setEMSProgramorSubroutineName("program name"); //expect false since program doesnt exist //EXPECT_EQ(false, setprogram); @@ -122,9 +121,10 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) // add program EnergyManagementSystemProgram program(model); program.setName("program 1"); - bool setprogram = outvar.setEMSProgramorSubroutineName(program); + bool setprogram = outvar.setEMSProgramOrSubroutineName(program); EXPECT_EQ(true, setprogram); - EXPECT_EQ("program_1", outvar.eMSProgramorSubroutineName().get()); + EXPECT_EQ("program_1", outvar.emsProgramOrSubroutineName()); + EXPECT_EQ(program, outvar.emsProgram()); // add output variable actuator @@ -139,9 +139,9 @@ TEST_F(ModelFixture, EMSOutputVariable_EMSOutputVariable) outvar_sen.setName("outputVar sen"); EXPECT_EQ("outputVar sen", outvar_sen.nameString()); - ASSERT_TRUE(outvar_sen.eMSVariableObject()); + ASSERT_TRUE(outvar_sen.emsVariableObject()); ASSERT_TRUE(outvar_sen.emsSensor()); - EXPECT_EQ(outvar_sen.eMSVariableObject().get(), outvar_sen.emsSensor().get()); + EXPECT_EQ(outvar_sen.emsVariableObject().get(), outvar_sen.emsSensor().get()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp index f14981b0354..cdf2f184f71 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgramCallingManager_GTest.cpp @@ -149,7 +149,7 @@ TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) bool callpt = fan_pcm.setCallingPoint("BeginNewEnvironment"); EXPECT_EQ(true, callpt); - EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint().get()); + EXPECT_EQ("BeginNewEnvironment", fan_pcm.callingPoint()); //should start with 0 programs std::vector programs = fan_pcm.programs(); @@ -198,10 +198,6 @@ TEST_F(ModelFixture, EMSProgramCallingManager_EMSProgramCallingManager) //erase program 3 in 2nd slot bool erase_prog = fan_pcm.eraseProgram(1); EXPECT_EQ(true, erase_prog); - //check for null programs - std::vector nullProgs = fan_pcm.nullPrograms(); - //should not be any if erasePrograms reindexed correctly - EXPECT_EQ(0, nullProgs.size()); //check program name is back to program 2's program = fan_pcm.getProgram(1); EXPECT_EQ(true, program.is_initialized()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp index a4b75cd5019..4b5ae3c8fec 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemProgram_GTest.cpp @@ -195,7 +195,7 @@ TEST_F(ModelFixture, EMSProgram_EMSProgram) lines = fan_program_3.lines(); EXPECT_EQ(3, lines.get().size()); EXPECT_EQ(line1_test, lines.get()[2]); - fan_program_3.eraseBody(); + fan_program_3.resetBody(); body = fan_program_3.body(); EXPECT_EQ("", body.get()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp index 4479c63c25d..e522b74ff70 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSensor_GTest.cpp @@ -64,7 +64,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("OATdb_Sensor", OATdbSensor.nameString()); EXPECT_EQ(siteOutdoorAirDrybulbTemperature.handle(), OATdbSensor.outputVariable().get().handle() ); EXPECT_EQ(siteOutdoorAirDrybulbTemperature, OATdbSensor.outputVariable()); - EXPECT_EQ("", OATdbSensor.keyName().get()); + EXPECT_EQ("", OATdbSensor.keyName()); // add Zone Lights Electric Power to both zones OutputVariable lightsElectricPower("Zone Lights Electric Power", model); @@ -77,7 +77,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) //lights.setOutputVariable(lightsElectricPower); lights.setKeyName(zone1.name().get()); - EXPECT_EQ(zone1.name().get(), lights.keyName().get()); + EXPECT_EQ(zone1.name().get(), lights.keyName()); EXPECT_EQ("Light_Sensor", lights.nameString()); // create meter @@ -92,7 +92,7 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EXPECT_EQ("meter_sensor", meter_sensor.nameString()); EXPECT_EQ(meter.handle(), meter_sensor.outputMeter().get().handle()); EXPECT_EQ(meter, meter_sensor.outputMeter()); - EXPECT_EQ("", meter_sensor.keyName().get()); + EXPECT_EQ("", meter_sensor.keyName()); ASSERT_TRUE(OATdbSensor.outputVariable()); ASSERT_FALSE(OATdbSensor.outputMeter()); @@ -110,7 +110,6 @@ TEST_F(ModelFixture, EMSSensor_EMSSensor) EnergyManagementSystemSensor sensor_string(model, "Sensor String"); sensor_string.setName("Sensor String Name"); EXPECT_EQ("Sensor_String_Name", sensor_string.nameString()); - ASSERT_TRUE(sensor_string.outputVariableOrMeterName()); - EXPECT_EQ("Sensor String", sensor_string.outputVariableOrMeterName().get()); + EXPECT_EQ("Sensor String", sensor_string.outputVariableOrMeterName()); } diff --git a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp index f5ca0a1de33..a4dad6f75e2 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemSubroutine_GTest.cpp @@ -196,7 +196,7 @@ TEST_F(ModelFixture, EMSSubroutine_EMSSubroutine) lines = fan_program_3.lines(); EXPECT_EQ(3, lines.get().size()); EXPECT_EQ(line1_test, lines.get()[2]); - fan_program_3.eraseBody(); + fan_program_3.resetBody(); body = fan_program_3.body(); EXPECT_EQ("", body.get()); diff --git a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp index f84bac54a73..4a8bc273157 100644 --- a/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp +++ b/openstudiocore/src/model/test/EnergyManagementSystemTrendVariable_GTest.cpp @@ -47,10 +47,10 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) var.setName("TestName"); EXPECT_EQ("TestName", var.name().get()); //var.setEMSVariableName("glob_var"); - EXPECT_EQ("glob_var", var.eMSVariableName()); + EXPECT_EQ("glob_var", var.emsVariableName()); - var.setNumberofTimestepstobeLogged(2); - EXPECT_EQ(2, var.numberofTimestepstobeLogged()); + var.setNumberOfTimestepsToBeLogged(2); + EXPECT_EQ(2, var.numberOfTimestepsToBeLogged()); EXPECT_EQ(globvar,var.emsGlobalVariable().get()); @@ -58,10 +58,10 @@ TEST_F(ModelFixture, EMSTrendVariable_EMSTrendVariable) EnergyManagementSystemGlobalVariable globvar2(model, "glob var2"); EnergyManagementSystemTrendVariable var2(model, globvar2); - EXPECT_EQ("glob_var2", var2.eMSVariableName()); - ASSERT_TRUE(var2.eMSVariableObject()); + EXPECT_EQ("glob_var2", var2.emsVariableName()); + ASSERT_TRUE(var2.emsVariableObject()); ASSERT_TRUE(var2.emsGlobalVariable()); EXPECT_EQ(globvar2, var2.emsGlobalVariable().get()); - EXPECT_EQ(var2.eMSVariableObject().get(), var2.emsGlobalVariable().get()); + EXPECT_EQ(var2.emsVariableObject().get(), var2.emsGlobalVariable().get()); } From a4c45606786533503b8e26ee2db67a8a50f552d0 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Wed, 19 Oct 2016 14:18:43 -0600 Subject: [PATCH 158/159] look for UIDs in Sensor keyName on FT --- ...dTranslateEnergyManagementSystemSensor.cpp | 27 +++++++++- .../src/energyplus/Test/EMS_GTest.cpp | 50 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp index 9b31ee4d92d..b31c257d7a8 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemSensor.cpp @@ -29,6 +29,8 @@ #include "../../model/EnergyManagementSystemSensor.hpp" #include "../../model/EnergyManagementSystemSensor_Impl.hpp" +#include "../../utilities/core/UUID.hpp" +#include "../../utilities/core/StringHelpers.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -57,7 +59,30 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemSen } s = modelObject.keyName(); if (s) { - idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, s.get()); + //find uids + const int subs[] = {1}; + std::string newline = s.get(); + std::string possible_uid; + size_t pos; + const Model m = modelObject.model(); + boost::optional mObject; + + boost::sregex_token_iterator j(s.get().begin(), s.get().end(), uuidInString(), subs); + + while (j != boost::sregex_token_iterator()) { + possible_uid = *j++; + //look to see if uid is in the model and return the object + UUID uid = toUUID(possible_uid); + mObject = m.getModelObject(uid); + if (mObject) { + //replace uid with namestring + pos = newline.find(possible_uid); + if (pos + 38 <= newline.length()) { + newline.replace(pos, 38, mObject.get().nameString()); + } + } + } + idfObject.setString(EnergyManagementSystem_SensorFields::Output_VariableorOutput_MeterIndexKeyName, newline); } d = modelObject.outputVariable(); if (d.is_initialized()) { diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index 2df2b23efc5..dfa477f5078 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -99,6 +99,10 @@ #include "../../model/SubSurface.hpp" #include "../../model/SubSurface_Impl.hpp" #include "../../model/LifeCycleCost.hpp" +#include "../../model/LifeCycleCost_Impl.hpp" +#include "../../model/CoilCoolingDXSingleSpeed.hpp" +#include "../../model/CoilCoolingDXSingleSpeed_Impl.hpp" + #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" @@ -196,6 +200,52 @@ TEST_F(EnergyPlusFixture,ForwardTranslatorSensor1_EMS) { workspace.save(toPath("./EMS_sensor1.idf"), true); } +TEST_F(EnergyPlusFixture, ForwardTranslatorSensorRename_EMS) { + + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + Schedule s = model.alwaysOnDiscreteSchedule(); + CurveBiquadratic totalCoolingCapacityFunctionofTemperatureCurve(model); + CurveQuadratic totalCoolingCapacityFunctionofFlowFractionCurve(model); + CurveBiquadratic energyInputRatioFunctionofTemperatureCurve(model); + CurveQuadratic energyInputRatioFunctionofFlowFractionCurve(model); + CurveQuadratic partLoadFractionCorrelationCurve(model); + // make cooling coil + CoilCoolingDXSingleSpeed dx_coil(model, s, + totalCoolingCapacityFunctionofTemperatureCurve, + totalCoolingCapacityFunctionofFlowFractionCurve, + energyInputRatioFunctionofTemperatureCurve, + energyInputRatioFunctionofFlowFractionCurve, + partLoadFractionCorrelationCurve); + + dx_coil.setName("Coil Name Before Change"); + EXPECT_EQ("Coil Name Before Change",dx_coil.nameString()); + + // add sensor + EnergyManagementSystemSensor sensor(model, "Cooling Coil Runtime Fraction"); + sensor.setKeyName(toString(dx_coil.handle())); + + //change name + dx_coil.setName("New Coil Name"); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::Coil_Cooling_DX_SingleSpeed).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::Coil_Cooling_DX_SingleSpeed)[0]; + + EXPECT_EQ("New Coil Name", object.nameString()); + + model.save(toPath("./EMS_sensorRename.osm"), true); + workspace.save(toPath("./EMS_sensorRename.idf"), true); +} + TEST_F(EnergyPlusFixture, ReverseTranslatorSensor1_EMS) { openstudio::path idfPath = toPath("./EMS_sensor1.idf"); From ac7f8dba0508c79c69cb6296894a7dd86dcac7d9 Mon Sep 17 00:00:00 2001 From: Brian Ball Date: Mon, 5 Dec 2016 10:15:53 -0700 Subject: [PATCH 159/159] add weather file functionality to Actuator --- ...ranslateEnergyManagementSystemActuator.cpp | 19 +++-- .../src/energyplus/Test/EMS_GTest.cpp | 84 +++++++++++++++++++ 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp index f2a28d4b734..95c2f77488a 100644 --- a/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp +++ b/openstudiocore/src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.cpp @@ -20,6 +20,7 @@ #include "../ForwardTranslator.hpp" #include "../../model/Model.hpp" +#include "../../model/ModelObject.hpp" #include "../../model/OutputVariable.hpp" #include "../../model/OutputVariable_Impl.hpp" #include "../../model/OutputMeter.hpp" @@ -28,6 +29,8 @@ #include "../../model/Schedule_Impl.hpp" #include "../../model/EnergyManagementSystemActuator.hpp" #include "../../model/EnergyManagementSystemActuator_Impl.hpp" +#include "../../model/Site.hpp" +#include "../../model/WeatherFile.hpp" #include #include "../../utilities/idd/IddEnums.hpp" @@ -52,12 +55,18 @@ boost::optional ForwardTranslator::translateEnergyManagementSystemAct if (s) { idfObject.setName(*s); } - - idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, modelObject.actuatedComponent().nameString()); - + const ModelObject m = modelObject.actuatedComponent(); + if (m.iddObjectType() == openstudio::IddObjectType::OS_Site || m.iddObjectType() == openstudio::IddObjectType::OS_WeatherFile) { + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, "Environment"); + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, "Weather Data"); + } + else { + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, m.nameString()); + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); + + } + idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); - - idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); return idfObject; } diff --git a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp index dfa477f5078..9e9632a303c 100644 --- a/openstudiocore/src/energyplus/Test/EMS_GTest.cpp +++ b/openstudiocore/src/energyplus/Test/EMS_GTest.cpp @@ -27,6 +27,10 @@ #include "../../model/Model.hpp" #include "../../model/Building.hpp" #include "../../model/Building_Impl.hpp" +#include "../../model/Site.hpp" +#include "../../model/Site_Impl.hpp" +#include "../../model/WeatherFile.hpp" +#include "../../model/WeatherFile_Impl.hpp" #include "../../model/ThermalZone.hpp" #include "../../model/Component.hpp" #include "../../model/CFactorUndergroundWallConstruction.hpp" @@ -407,6 +411,86 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorActuator_EMS) { } +TEST_F(EnergyPlusFixture, ForwardTranslatorWeatherActuator_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // weatherFile + WeatherFile weatherFile = model.getUniqueModelObject(); + EXPECT_TRUE(model.getOptionalUniqueModelObject()); + + // add actuator + std::string controlType = "Outdoor Dry Bulb"; + std::string componentType = "Weather Data"; + EnergyManagementSystemActuator weatherActuator(weatherFile, componentType, controlType); + std::string actuatorName = "Weather_Actuator"; + weatherActuator.setName(actuatorName); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::Name, false)); + EXPECT_EQ(actuatorName, object.getString(EnergyManagementSystem_ActuatorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false)); + EXPECT_EQ("Environment", object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false)); + EXPECT_EQ(componentType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false)); + EXPECT_EQ(controlType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false).get()); + + model.save(toPath("./EMS_weatheractuator.osm"), true); + workspace.save(toPath("./EMS_weatheractuator.idf"), true); +} + +TEST_F(EnergyPlusFixture, ForwardTranslatorWeatherActuator2_EMS) { + Model model; + + Building building = model.getUniqueModelObject(); + + ThermalZone zone1(model); + ThermalZone zone2(model); + + // get site + Site site = model.getUniqueModelObject(); + EXPECT_TRUE(model.getOptionalUniqueModelObject()); + //OptionalSite oSite = model.getOptionalUniqueModelObject(); + //EXPECT_TRUE(oSite); + + // add actuator + std::string controlType = "Outdoor Dry Bulb"; + std::string componentType = "Weather Data"; + EnergyManagementSystemActuator weatherActuator(site, componentType, controlType); + std::string actuatorName = "Weather_Actuator"; + weatherActuator.setName(actuatorName); + + ForwardTranslator forwardTranslator; + Workspace workspace = forwardTranslator.translateModel(model); + EXPECT_EQ(0u, forwardTranslator.errors().size()); + EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator).size()); + + WorkspaceObject object = workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_Actuator)[0]; + + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::Name, false)); + EXPECT_EQ(actuatorName, object.getString(EnergyManagementSystem_ActuatorFields::Name, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false)); + EXPECT_EQ("Environment", object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false)); + EXPECT_EQ(componentType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, false).get()); + ASSERT_TRUE(object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false)); + EXPECT_EQ(controlType, object.getString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, false).get()); + + model.save(toPath("./EMS_weatheractuator2.osm"), true); + workspace.save(toPath("./EMS_weatheractuator2.idf"), true); +} + TEST_F(EnergyPlusFixture, ForwardTranslatorProgram_EMS) { Model model;