Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/NREL/OpenStudio into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
kbenne committed Dec 5, 2016
2 parents 0215062 + e0636e1 commit 2973101
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <utilities/idd/EnergyManagementSystem_Actuator_FieldEnums.hxx>
#include "../../utilities/idd/IddEnums.hpp"
Expand All @@ -52,12 +55,18 @@ boost::optional<IdfObject> 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;
}
Expand Down
4 changes: 2 additions & 2 deletions openstudiocore/src/energyplus/ReverseTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class ENERGYPLUS_API ReverseTranslator {
boost::optional<model::ModelObject> translateElectricEquipment(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateElectricLoadCenterStorageSimple(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateElectricLoadCenterStorageConverter(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateEnergyManagementSystemActuator(const WorkspaceObject & workspaceObject);

Expand All @@ -168,8 +170,6 @@ class ENERGYPLUS_API ReverseTranslator {

boost::optional<model::ModelObject> translateEnergyManagementSystemSensor(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateElectricLoadCenterStorageConverter(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateEnergyManagementSystemSubroutine(const WorkspaceObject & workspaceObject);

boost::optional<model::ModelObject> translateEnergyManagementSystemTrendVariable(const WorkspaceObject & workspaceObject);
Expand Down
84 changes: 84 additions & 0 deletions openstudiocore/src/energyplus/Test/EMS_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -407,6 +411,86 @@ TEST_F(EnergyPlusFixture, ReverseTranslatorActuator_EMS) {

}

TEST_F(EnergyPlusFixture, ForwardTranslatorWeatherActuator_EMS) {
Model model;

Building building = model.getUniqueModelObject<Building>();

ThermalZone zone1(model);
ThermalZone zone2(model);

// weatherFile
WeatherFile weatherFile = model.getUniqueModelObject<WeatherFile>();
EXPECT_TRUE(model.getOptionalUniqueModelObject<WeatherFile>());

// 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<Building>();

ThermalZone zone1(model);
ThermalZone zone2(model);

// get site
Site site = model.getUniqueModelObject<Site>();
EXPECT_TRUE(model.getOptionalUniqueModelObject<Site>());
//OptionalSite oSite = model.getOptionalUniqueModelObject<Site>();
//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;

Expand Down

9 comments on commit 2973101

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (kbenne) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2312 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (kbenne) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (kbenne) - i386-Windows-7-VisualStudio-12: OK (2337 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (kbenne) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2313 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (kbenne) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (kbenne) - Win64-Windows-7-VisualStudio-12: OK (2337 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (kbenne) - i386-Windows-7-VisualStudio-12: OK (2336 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (kbenne) - Win64-Windows-7-VisualStudio-12: Tests Failed (2199 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iteration (kbenne) - x86_64-MacOS-10.10-clang: OK (2338 of 2510 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.