Esempio n. 1
0
void TreeModel::getObjectNames(const openstudio::model::ModelObject& object, QList<QVariant>& objectNames)
{


  IddObject iddObject = object.iddObject();
  QString objectName(iddObject.name().c_str());
  // object might have a name
  OptionalString optionalString = object.name();
  if(optionalString){
    QString name = optionalString.get().c_str();
    int firstIdx = name.indexOf(guidOpenCurlyBrace);
    int secondIdx = name.indexOf(guidCloseCurlyBrace);
    if(mMaskGUIDs && (firstIdx != -1) && (secondIdx != -1)){
      ///! QString::trimmed() won't work due to characters after the last curly brace
      unsigned offset = 0;
      if(firstIdx>0 && firstIdx<name.size() && name.at(firstIdx-1).isSpace()){
        offset++;
      }
      name.remove(firstIdx-offset,secondIdx-firstIdx+1+offset);
    }
    objectName += " (";
    objectName += name.toStdString().c_str();
    objectName += ")";
  }
  objectNames.push_back(objectName);
}
Esempio n. 2
0
TEST_F(IddFixture,IddKey_Getters) {
  OptionalIddObject optObject = IddFactory::instance().getObject(IddObjectType::Controller_OutdoorAir);
  ASSERT_TRUE(optObject);
  IddObject obj = *optObject;
  OptionalIddField f = obj.getField(Controller_OutdoorAirFields::EconomizerControlType);
  ASSERT_TRUE(f);
  EXPECT_TRUE(f->properties().type == IddFieldType::ChoiceType);
  IddKeyVector keys = f->keys();
  EXPECT_EQ(static_cast<unsigned>(8),keys.size());
  LOG(Info,"Keys for field " << Controller_OutdoorAirFields::EconomizerControlType 
      << ", " << f->name() << ", of IddObject " << obj.name() << ":");
  unsigned i = 0;
  BOOST_FOREACH(IddKey& key,keys) {
    LOG(Info,"  Key " << i << ": " << key.name());
    ++i;
  }
Esempio n. 3
0
TEST_F(IddFixture,IddObject_ExtensibleIndex) {
  OptionalIddObject oio = IddFactory::instance().getObject(IddObjectType::BuildingSurface_Detailed);
  ASSERT_TRUE(oio);
  IddObject iddObj = *oio;

  ExtensibleIndex extInd(0,0);
  unsigned ind = iddObj.index(extInd);
  EXPECT_EQ(static_cast<unsigned>(10),ind);

  extInd.field = 2;
  ind = iddObj.index(extInd);
  EXPECT_EQ(static_cast<unsigned>(12),ind);

  extInd.group = 5;
  ind = iddObj.index(extInd);
  EXPECT_EQ(static_cast<unsigned>(27),ind);

  ind = 19;
  extInd = iddObj.extensibleIndex(ind);
  EXPECT_EQ(static_cast<unsigned>(3),extInd.group);
  EXPECT_EQ(static_cast<unsigned>(0),extInd.field);

  ind = 26;
  extInd = iddObj.extensibleIndex(ind);
  EXPECT_EQ(static_cast<unsigned>(5),extInd.group);
  EXPECT_EQ(static_cast<unsigned>(1),extInd.field);
}
TEST_F(IddFixture,IddFactory_IddObjects)
{
    IddObject object;

    OptionalIddObject candidate = IddFactory::instance().getObject(IddObjectType::UserCustom);
    EXPECT_FALSE(candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::Catchall);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("catchall");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::CommentOnly);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("coMmentonLy");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);

    candidate = IddFactory::instance().getObject(IddObjectType::Lights);
    ASSERT_TRUE(candidate);
    object = *candidate;
    candidate = IddFactory::instance().getObject("lights");
    ASSERT_TRUE(candidate);
    EXPECT_TRUE(object == *candidate);
    EXPECT_EQ("Lights", object.name());
    ASSERT_TRUE(object.nonextensibleFields().size() > static_cast<unsigned>(0));
    EXPECT_EQ("Return Air Fraction Function of Plenum Temperature Coefficient 2",
              object.nonextensibleFields().back().name());

    OptionalIddField field = object.getField(0);
    ASSERT_TRUE(field);
    EXPECT_EQ("Name",field->name());
    EXPECT_TRUE(field->properties().required);
    EXPECT_EQ(IddFieldType(IddFieldType::AlphaType),field->properties().type);
    ASSERT_TRUE(!field->properties().references.empty());
    EXPECT_EQ(static_cast<unsigned>(1), field->properties().references.size());
    EXPECT_EQ("LightsNames", *(field->properties().references.begin()));
    EXPECT_FALSE(field->properties().stringDefault); // OptionalString should be false--no default name
    EXPECT_EQ(IddFieldProperties::Unbounded,field->properties().minBoundType);

    ASSERT_TRUE(object.nonextensibleFields().size() > static_cast<unsigned>(3));
    field = object.getField(3);
    EXPECT_EQ("Design Level Calculation Method",field->name());
    EXPECT_FALSE(field->properties().required);
    EXPECT_TRUE(field->properties().stringDefault);
    EXPECT_EQ("LightingLevel",*(field->properties().stringDefault));
    EXPECT_EQ(IddFieldType(IddFieldType::ChoiceType),field->properties().type);
    EXPECT_EQ(static_cast<unsigned>(3),field->keys().size());
}
 bool operator()(const IddObject& object) {
     // fields that are \autocalculatable with no default, or a default other than 'autocalculate',
     // or fields that are \autosizable with no default or a default other than 'autosize'.
     for (const IddField& iddField : object.nonextensibleFields()) {
         if (iddField.properties().autocalculatable && (!iddField.properties().stringDefault ||
                 !istringEqual("autocalculate",iddField.properties().stringDefault.get())))
         {
             return true;
         }
         if (iddField.properties().autosizable && (!iddField.properties().stringDefault ||
                 !istringEqual("autosize",iddField.properties().stringDefault.get())))
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 6
0
TEST_F(IddFixture,IddObject_InsertHandleField) {
  // Test on EnergyPlus IDD object since no handles there
  // Use object with mix of A's and N's
  IddObjectType type(IddObjectType::HeatBalanceAlgorithm);
  IddObject temp = IddFactory::instance().getObject(type).get();
  std::stringstream ss;
  temp.print(ss);
  IddObject object = IddObject::load("HeatBalanceAlgorithm","Simulation Control",ss.str()).get();
  object.insertHandleField();
  EXPECT_EQ("A1",object.getField(0).get().fieldId());
  EXPECT_EQ("A2",object.getField(1).get().fieldId());
  EXPECT_EQ("N1",object.getField(2).get().fieldId());
}