Example #1
0
  bool Node_Impl::isConnected(const ModelObject & modelObject)
  {
    if( auto mo = outletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }
    if( auto mo = inletModelObject() ) {
      if( modelObject.handle() == mo->handle() ) {
        return true;
      }
    }

    return false;
  }
unsigned ZoneHVACEquipmentList_Impl::coolingPriority(const ModelObject & equipment)
{
  boost::optional<unsigned> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == equipment.handle() )
    {
      result = it->getUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence);

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
WorkspaceExtensibleGroup ZoneHVACEquipmentList_Impl::getGroupForModelObject(const ModelObject & modelObject)
{
  boost::optional<WorkspaceExtensibleGroup> result;

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == modelObject.handle() )
    {
      result = it->cast<WorkspaceExtensibleGroup>();

      break;
    }
  }

  OS_ASSERT(result);

  return result.get();
}
  bool ModelObjectList_Impl::addModelObject(const ModelObject& modelObject ) {
    WorkspaceExtensibleGroup eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>();

    bool ok = eg.setPointer(OS_ModelObjectListExtensibleFields::ModelObject,modelObject.handle());

    if( !ok ) {
      getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex());
    }
    return ok;
  }
Example #5
0
 bool ComponentData_Impl::registerObject(const ModelObject& object) {
   IdfExtensibleGroup eg = pushExtensibleGroup(StringVector());
   bool result = !eg.empty();
   if (result) {
     ModelExtensibleGroup meg = eg.cast<ModelExtensibleGroup>();
     result = result && meg.setPointer(OS_ComponentDataExtensibleFields::NameofObject,
                                       object.handle());
   }
   return result;
 }
Example #6
0
TEST_F(ModelFixture, Construction_Clone)
{
  Model library;

  // Create some materials
  StandardOpaqueMaterial exterior(library);
  AirGap air(library);
  StandardOpaqueMaterial interior(library);

  OpaqueMaterialVector layers;
  layers.push_back(exterior);
  layers.push_back(air);
  layers.push_back(interior);

  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  Construction construction(layers);
  ASSERT_EQ(static_cast<unsigned>(3), construction.layers().size());

  // Clone into same model
  ModelObject clone = construction.clone(library);

  // Material ResourceObject instances are shared resources so they have not been cloned
  EXPECT_EQ(static_cast<unsigned>(3), library.getModelObjects<Material>().size());

  // New handle for cloned construction
  EXPECT_FALSE(clone.handle() == construction.handle());
  ASSERT_TRUE(clone.optionalCast<Construction>());

  ASSERT_EQ(static_cast<unsigned>(3), clone.cast<Construction>().layers().size());

  // Clone into a differnt model
  Model model;

  auto clone2 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(1), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone2.cast<Construction>().layers().size());

  // Clone again
  auto clone3 = construction.clone(model).cast<Construction>();
  EXPECT_EQ(static_cast<unsigned>(3), model.getModelObjects<Material>().size());

  EXPECT_EQ(static_cast<unsigned>(2), model.getModelObjects<Construction>().size());

  // Make sure materials are still hooked up
  ASSERT_EQ(static_cast<unsigned>(3), clone3.cast<Construction>().layers().size());

  EXPECT_FALSE(clone2.handle() == clone3.handle());
}
void ZoneHVACEquipmentList_Impl::removeEquipment(const ModelObject & equipment)
{
  std::vector<ModelObject> coolingVector = equipmentInCoolingOrder();
  std::vector<ModelObject> heatingVector = equipmentInHeatingOrder();

  std::vector<IdfExtensibleGroup> groups = extensibleGroups();

  for( std::vector<IdfExtensibleGroup>::iterator it = groups.begin();
       it != groups.end();
       ++it )
  {
    boost::optional<WorkspaceObject> wo = it->cast<WorkspaceExtensibleGroup>().getTarget(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment);

    OS_ASSERT(wo);

    if( wo->handle() == equipment.handle() )
    {
      getObject<ModelObject>().eraseExtensibleGroup(it->groupIndex());

      break;
    }
  }

  coolingVector.erase(std::find(coolingVector.begin(),coolingVector.end(),equipment));
  heatingVector.erase(std::find(heatingVector.begin(),heatingVector.end(),equipment));

  unsigned priority = 1;

  for( std::vector<ModelObject>::iterator it = coolingVector.begin();
       it != coolingVector.end();
       ++it )
  {
    WorkspaceExtensibleGroup eg = getGroupForModelObject(*it);

    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence,priority);

    priority++;
  }

  priority = 1;

  for( std::vector<ModelObject>::iterator it = heatingVector.begin();
       it != heatingVector.end();
       ++it )
  {
    WorkspaceExtensibleGroup eg = getGroupForModelObject(*it);

    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentHeatingorNoLoadSequence,priority);

    priority++;
  }

}
void ZoneHVACEquipmentList_Impl::addEquipment(const ModelObject & equipment)
{
  unsigned count = this->equipment().size();

  WorkspaceExtensibleGroup eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>();

  bool ok = eg.setPointer(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipment,equipment.handle());

  if( ok )
  {
    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence,count + 1);
    eg.setUnsigned(OS_ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentHeatingorNoLoadSequence,count + 1);
  }
  else
  {
    getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex());
  }
}
Example #9
0
ScheduleRule::ScheduleRule(ScheduleRuleset& scheduleRuleset, const ScheduleDay& daySchedule)
  : ParentObject(ScheduleRule::iddObjectType(), scheduleRuleset.model())
{
  OS_ASSERT(getImpl<detail::ScheduleRule_Impl>());

  bool result = setPointer(OS_Schedule_RuleFields::ScheduleRulesetName, scheduleRuleset.handle());
  OS_ASSERT(result); 

  ModelObject clone = daySchedule.clone(scheduleRuleset.model());
  result = setPointer(OS_Schedule_RuleFields::DayScheduleName, clone.handle());
  OS_ASSERT(result); 
  if (OptionalScheduleTypeLimits limits = scheduleRuleset.scheduleTypeLimits()) {
    clone.cast<ScheduleDay>().setScheduleTypeLimits(*limits);
  }

  this->setRuleIndex(std::numeric_limits<int>::max());
  result = scheduleRuleset.setScheduleRuleIndex(*this, 0);
  OS_ASSERT(result);
}
Example #10
0
std::vector<ModelObject> getRecursiveChildrenAndResources(const ModelObject& object) {
  std::set<Handle> resultSet;
  std::pair<HandleSet::const_iterator,bool> insertResult;
  std::vector<ModelObject> result;
  resultSet.insert(object.handle());
  result.push_back(object);

  std::deque<ModelObject> objectQueue;
  objectQueue.push_back(object);

  while (objectQueue.size() > 0) {
    ModelObject currentObject(objectQueue[0]);
    objectQueue.pop_front();
    // resources
    for (const ResourceObject& resource : currentObject.resources()) {
      insertResult = resultSet.insert(resource.handle());
      if (insertResult.second) {
        // new object
        ModelObject mo = resource.cast<ModelObject>();
        result.push_back(mo);
        objectQueue.push_back(mo);
      }
    }
    // children
    OptionalParentObject opo = currentObject.optionalCast<ParentObject>();
    if (opo) {
      ParentObject currentParent(*opo);
      for (const ModelObject& child : currentParent.children()) {
        insertResult = resultSet.insert(child.handle());
        if (insertResult.second) {
          // new object
          result.push_back(child);
          objectQueue.push_back(child);
        }
      }
    }
  }

  return result;
}
Example #11
0
  WorkspaceExtensibleGroup ModelObjectList_Impl::getGroupForModelObject(const ModelObject& modelObject)
  {
    boost::optional<WorkspaceExtensibleGroup> result;

    std::vector<IdfExtensibleGroup> groups = extensibleGroups();

    for( const auto & group : groups )
    {
      boost::optional<WorkspaceObject> wo = group.cast<WorkspaceExtensibleGroup>().getTarget(OS_ModelObjectListExtensibleFields::ModelObject);

      OS_ASSERT(wo);

      if( wo->handle() == modelObject.handle() )
      {
        result = group.cast<WorkspaceExtensibleGroup>();

        break;
      }
    }

    OS_ASSERT(result);

    return result.get();
  }
Example #12
0
 bool Connection_Impl::setTargetObject(ModelObject object)
 {
   return setPointer(openstudio::OS_ConnectionFields::TargetObject,object.handle());;
 }
Example #13
0
 void Connection_Impl::setSourceObject(ModelObject object)
 {
   setPointer(openstudio::OS_ConnectionFields::SourceObject,object.handle());
 }
 bool ExternalInterfaceFunctionalMockupUnitImportToActuator_Impl::setActuatedComponentUnique(const ModelObject& modelObject) {
   bool result = setPointer(OS_ExternalInterface_FunctionalMockupUnitImport_To_ActuatorFields::ActuatedComponentUniqueName, modelObject.handle());
   return result;
 }
Example #15
0
 bool RefrigerationSystem_Impl::setRefrigerationCondenser(const ModelObject& refrigerationCondenser) {
   bool result = setPointer(OS_Refrigeration_SystemFields::RefrigerationCondenserName, refrigerationCondenser.handle());
   return result;
 }