Ejemplo n.º 1
0
TEST_F(ModelFixture, ComponentWatcher_InComponent) {
  // create Component. ComponentWatcher should work here too (since Component is Model)
  Model model;
  DesignDay designDay(model);
  EXPECT_EQ(1u,model.numObjects());
  Component designDayComponent = designDay.createComponent();
  EXPECT_EQ(2u,designDayComponent.numObjects());
  ComponentData cd = designDayComponent.componentData();
  UUID versionUUID = cd.versionUUID();
  designDay = designDayComponent.primaryObject().cast<DesignDay>();

  // data changes ok--changes version
  EXPECT_TRUE(designDay.setName("My Design Day"));
  EXPECT_NE(versionUUID,cd.versionUUID());
  versionUUID = cd.versionUUID();

  // trying to assign contents results in refresh of contents
  IdfExtensibleGroup eg = cd.getExtensibleGroup(0);
  ASSERT_FALSE(eg.empty());
  std::string originalValue = eg.getString(0).get();
  EXPECT_FALSE(eg.setString(0,"Material"));
  EXPECT_TRUE(cd.initialized());
  EXPECT_EQ(2u,designDayComponent.numObjects());
  EXPECT_EQ(originalValue,eg.getString(0).get());
}
Ejemplo n.º 2
0
TEST_F(ModelFixture, ComponentWatcher_ComponentData_Interactions) {

  // create osm file that contains ComponentData
  Model model;
  DesignDay designDay(model);
  EXPECT_EQ(1u,model.numObjects());
  Component designDayComponent = designDay.createComponent();
  ComponentData componentData = designDayComponent.componentData();
  UUID uuid = componentData.uuid();
  UUID versionUUID = componentData.versionUUID();
  EXPECT_FALSE(versionUUID.isNull());
  model = Model();
  EXPECT_EQ(0u,model.numObjects());
  OptionalComponentData ocd = model.insertComponent(designDayComponent);
  ASSERT_TRUE(ocd);
  EXPECT_EQ(2u,model.numObjects());

  // simple insert should not change component UUIDs.
  componentData = *ocd;
  EXPECT_EQ(uuid,componentData.uuid());
  EXPECT_EQ(versionUUID,componentData.versionUUID());

  // changing data fields of component objects causes version id to change
  componentData.primaryComponentObject().cast<DesignDay>().setMaximumDryBulbTemperature(50.0);
  EXPECT_EQ(uuid,componentData.uuid());
  EXPECT_NE(versionUUID,componentData.versionUUID());
  versionUUID = componentData.versionUUID();

  // trying to change contents field to an invalid value directly is not allowed
  IdfExtensibleGroup eg = componentData.getExtensibleGroup(0);
  ASSERT_FALSE(eg.empty());
  std::string originalValue = eg.getString(0).get();
  EXPECT_EQ("Sizing Period Design Day 1",originalValue);
  EXPECT_FALSE(eg.setString(0,"My Material"));
  EXPECT_TRUE(componentData.initialized());
  EXPECT_EQ(2u,model.numObjects());
  EXPECT_EQ(originalValue,eg.getString(0).get());

  // ComponentData.remove() is okay (should automatically delete the ComponentWatcher)
  ocd = model.insertComponent(designDayComponent);
  ASSERT_TRUE(ocd);
  // should find original DesignDay and reinstantiate ComponentData
  EXPECT_EQ(2u,model.numObjects());
  componentData = *ocd;
  ASSERT_TRUE(componentData.initialized());
  EXPECT_FALSE(componentData.remove().empty());
  EXPECT_EQ(static_cast<unsigned>(1),model.numObjects());
}
Ejemplo n.º 3
0
boost::optional<std::string> UtilityCost_Computation_Impl::computeStep(unsigned index) const {
  IdfExtensibleGroup eg = getExtensibleGroup(index);
  if (!eg.empty()) {
    return eg.getString(OS_UtilityCost_ComputationExtensibleFields::ComputeStep,true);
  }
  return boost::none;
}
boost::optional<std::string> UtilityCost_Charge_Block_Impl::blockCostPerUnitValueOrVariableName(unsigned index) const {
  IdfExtensibleGroup eg = getExtensibleGroup(index);
  if (!eg.empty()) {
    return eg.getString(OS_UtilityCost_Charge_BlockExtensibleFields::BlockCostperUnitValueorVariableName,true);
  }
  return boost::none;
}
Ejemplo n.º 5
0
 boost::optional<std::string> PeopleDefinition_Impl::getThermalComfortModelType(int i) const {
   OptionalString result;
   if (i < numThermalComfortModelTypes()) {
     IdfExtensibleGroup eg = getExtensibleGroup(i);
     OS_ASSERT(!eg.empty());
     result = eg.getString(OS_People_DefinitionExtensibleFields::ThermalComfortModelType,true);
   }
   return result;
 }