boost::optional<IdfObject> ForwardTranslator::translateExteriorLights( model::ExteriorLights& modelObject) { IdfObject idfObject(IddObjectType::Exterior_Lights); m_idfObjects.push_back(idfObject); idfObject.setString(Exterior_LightsFields::Name, modelObject.name().get()); OptionalIdfObject relatedIdfObject; model::Schedule schedule = modelObject.schedule(); relatedIdfObject = translateAndMapModelObject(schedule); OS_ASSERT(relatedIdfObject); idfObject.setString(Exterior_LightsFields::ScheduleName,relatedIdfObject->name().get()); model::ExteriorLightsDefinition definition = modelObject.exteriorLightsDefinition(); double designLevel = definition.designLevel()*modelObject.multiplier(); idfObject.setDouble(Exterior_LightsFields::DesignLevel,designLevel); if (!modelObject.isControlOptionDefaulted()) { idfObject.setString(Exterior_LightsFields::ControlOption,modelObject.controlOption()); } if (!modelObject.isEndUseSubcategoryDefaulted()) { idfObject.setString(Exterior_LightsFields::EndUseSubcategory,modelObject.endUseSubcategory()); } return idfObject; }
TEST_F(IdfFixture,IdfObject_URL) { std::string text = "Schedule:File,Dan,,file:///home/ramey/schedule.csv,1;"; OptionalIdfObject oObj = IdfObject::load(text); ASSERT_TRUE(oObj); boost::optional<QUrl> urlOpt = oObj->getURL(2); EXPECT_TRUE(urlOpt); cout <<"---------------------URL TEXT-------------------\n" << urlOpt->toString().toStdString() << endl; }
TEST_F(IdfFixture, IdfObject_GetQuantity) { std::string text = "Building, !- Building \n\ Building, !- Name \n\ 30., !- North Axis {deg} \n\ City, !- Terrain \n\ 0.04, !- Loads Convergence Tolerance Value \n\ 0.4, !- Temperature Convergence Tolerance Value {deltaC} \n\ FullExterior, !- Solar Distribution \n\ 25; !- Maximum Number of Warmup Days"; // make an idf object OptionalIdfObject oObj = IdfObject::load(text); ASSERT_TRUE(oObj); // Test get. OSOptionalQuantity ooq = oObj->getQuantity (4); ASSERT_TRUE(ooq.isSet()); Quantity q = ooq.get(); EXPECT_TRUE(q.value() == 0.4); EXPECT_TRUE(q.system() == UnitSystem::SI); EXPECT_TRUE(q.standardUnitsString() == "K"); // Test set. OptionalQuantity oq = convert(q,UnitSystem(UnitSystem::IP)); ASSERT_TRUE(oq); EXPECT_TRUE(oq->system() == UnitSystem::IP); EXPECT_DOUBLE_EQ(0.72,oq->value()); oq->setValue(1.5); EXPECT_TRUE(oObj->setQuantity(4, *oq)); ooq = oObj->getQuantity(4); ASSERT_TRUE(ooq.isSet()); q = ooq.get(); EXPECT_DOUBLE_EQ(0.83333333333333333,q.value()); EXPECT_TRUE(q.system() == UnitSystem::SI); EXPECT_TRUE(q.standardUnitsString() == "K"); }
boost::optional<IdfObject> ForwardTranslator::translateLights( Lights & modelObject ) { // create, register, and name object IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Lights, modelObject); for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()){ translateAndMapModelObject(lifeCycleCost); } LightsDefinition definition = modelObject.lightsDefinition(); OptionalIdfObject relatedIdfObject; boost::optional<Space> space = modelObject.space(); boost::optional<SpaceType> spaceType = modelObject.spaceType(); if (space){ boost::optional<ThermalZone> thermalZone = space->thermalZone(); if (thermalZone){ relatedIdfObject = translateAndMapModelObject(*thermalZone); OS_ASSERT(relatedIdfObject); idfObject.setString(LightsFields::ZoneorZoneListName, relatedIdfObject->name().get()); } }else if(spaceType){ relatedIdfObject = translateAndMapModelObject(*spaceType); OS_ASSERT(relatedIdfObject); idfObject.setString(LightsFields::ZoneorZoneListName, relatedIdfObject->name().get()); } boost::optional<Schedule> schedule = modelObject.schedule(); if (schedule){ relatedIdfObject = translateAndMapModelObject(*schedule); OS_ASSERT(relatedIdfObject); idfObject.setString(LightsFields::ScheduleName, relatedIdfObject->name().get()); } idfObject.setString(LightsFields::DesignLevelCalculationMethod, definition.designLevelCalculationMethod()); double multiplier = modelObject.multiplier(); boost::optional<double> d = definition.lightingLevel(); if (d){ idfObject.setDouble(LightsFields::LightingLevel, (*d)*multiplier); } d = definition.wattsperSpaceFloorArea(); if (d){ idfObject.setDouble(LightsFields::WattsperZoneFloorArea, (*d)*multiplier); } d = definition.wattsperPerson(); if (d){ idfObject.setDouble(LightsFields::WattsperPerson, (*d)*multiplier); } if (!definition.isReturnAirFractionDefaulted()){ idfObject.setDouble(LightsFields::ReturnAirFraction, definition.returnAirFraction()); } if (!definition.isFractionRadiantDefaulted()){ idfObject.setDouble(LightsFields::FractionRadiant, definition.fractionRadiant()); } if (!definition.isFractionVisibleDefaulted()){ idfObject.setDouble(LightsFields::FractionVisible, definition.fractionVisible()); } if (!modelObject.isFractionReplaceableDefaulted()){ idfObject.setDouble(LightsFields::FractionReplaceable, modelObject.fractionReplaceable()); } if (!modelObject.isEndUseSubcategoryDefaulted()){ idfObject.setString(LightsFields::EndUseSubcategory, modelObject.endUseSubcategory()); } if (!definition.isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted()){ if (definition.returnAirFractionCalculatedfromPlenumTemperature()){ idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature,"Yes"); }else{ idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature,"No"); } } if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted()){ idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1, definition.returnAirFractionFunctionofPlenumTemperatureCoefficient1()); } if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted()){ idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2, definition.returnAirFractionFunctionofPlenumTemperatureCoefficient2()); } return idfObject; }