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; }
boost::optional<double> LifeCycleCostUsePriceEscalation_Impl::yearEscalation(unsigned index) const { IdfExtensibleGroup eg = getExtensibleGroup(index); if (!eg.empty()) { return eg.getDouble(OS_LifeCycleCost_UsePriceEscalationExtensibleFields::YearEscalation,true); } return boost::none; }
ClimateZone ClimateZones_Impl::getClimateZone(unsigned index) const { IdfExtensibleGroup eg = getExtensibleGroup(index); if (eg.empty()) { std::shared_ptr<ClimateZones_Impl> p; return ClimateZone(p,numFields()); } return eg.cast<ClimateZone>(); }
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; }
bool UtilityCost_Computation_Impl::setComputeStep(unsigned index, const std::string& str) { IdfExtensibleGroup eg = getExtensibleGroup(index); if (!eg.empty()) { return eg.setString(OS_UtilityCost_ComputationExtensibleFields::ComputeStep,str); } else { StringVector values(1u,str); return !insertExtensibleGroup(index,values).empty(); } OS_ASSERT(false); return false; }
bool UtilityCost_Charge_Block_Impl::setBlockCostPerUnitValueOrVariableName(unsigned index, const std::string& str) { IdfExtensibleGroup eg = getExtensibleGroup(index); if (!eg.empty()) { return eg.setString(OS_UtilityCost_Charge_BlockExtensibleFields::BlockCostperUnitValueorVariableName,str); } else { StringVector values(2u); values[OS_UtilityCost_Charge_BlockExtensibleFields::BlockCostperUnitValueorVariableName] = str; return !insertExtensibleGroup(index,values).empty(); } OS_ASSERT(false); return false; }
bool LifeCycleCostUsePriceEscalation_Impl::setYearEscalation(unsigned index, double num) { IdfExtensibleGroup eg = getExtensibleGroup(index); if (!eg.empty()) { return eg.setDouble(OS_LifeCycleCost_UsePriceEscalationExtensibleFields::YearEscalation,num); } else { StringVector values(1u); eg = insertExtensibleGroup(index,values); if (!eg.empty()) { return eg.setDouble(OS_LifeCycleCost_UsePriceEscalationExtensibleFields::YearEscalation,num); } } return false; }
bool PeopleDefinition_Impl::setThermalComfortModelType( int i, const std::string& thermalComfortModelType) { int n = numThermalComfortModelTypes(); if (i == n) { return pushThermalComfortModelType(thermalComfortModelType); } if (i < n) { IdfExtensibleGroup eg = getExtensibleGroup(i); OS_ASSERT(!eg.empty()); return eg.setString(OS_People_DefinitionExtensibleFields::ThermalComfortModelType, thermalComfortModelType); } return false; }
bool ScheduleDay_Impl::addValue(const openstudio::Time& untilTime, double value) { if (untilTime.totalMinutes() <= 0.5 || untilTime.totalDays() > 1.0) { return false; } int untilHours = untilTime.hours() + 24*untilTime.days(); int untilMinutes = untilTime.minutes() + floor((untilTime.seconds()/60.0) + 0.5); if (untilMinutes >= 60){ untilHours += 1; untilMinutes += -60; } // use set to determine whether to overwrite or insert, and where std::set<openstudio::Time> times; std::pair<std::set<openstudio::Time>::const_iterator,bool> insertResult; for (const openstudio::Time& time : this->times()) { insertResult = times.insert(time); OS_ASSERT(insertResult.second); } insertResult = times.insert(untilTime); unsigned index = std::distance<std::set<openstudio::Time>::const_iterator>(times.begin(),insertResult.first); OS_ASSERT(index <= numExtensibleGroups()); bool result(true); if (insertResult.second) { // new time--insert an extensible group std::vector<std::string> groupValues; groupValues.push_back(boost::lexical_cast<std::string>(untilHours)); groupValues.push_back(boost::lexical_cast<std::string>(untilMinutes)); groupValues.push_back(toString(value)); IdfExtensibleGroup group = insertExtensibleGroup(index, groupValues); OS_ASSERT(!group.empty()); } else { // time already exists, overwrite value IdfExtensibleGroup group = getExtensibleGroup(index); result = group.setDouble(OS_Schedule_DayExtensibleFields::ValueUntilTime,value); } return result; }
ModelObject ComponentData_Impl::getComponentObject(unsigned objectIndex) const { if (objectIndex >= numComponentObjects()) { LOG_AND_THROW("objectIndex = " << objectIndex << " >= numComponentObjects() = " << numComponentObjects() << "."); } IdfExtensibleGroup eg = getExtensibleGroup(objectIndex); if (eg.empty()) { LOG_AND_THROW("Cannot retrieve IdfExtensibleGroup at objectIndex = " << objectIndex); } ModelExtensibleGroup componentObjectData = eg.cast<ModelExtensibleGroup>(); OptionalModelObject omo = componentObjectData.getModelObjectTarget<ModelObject>( OS_ComponentDataExtensibleFields::NameofObject); if (!omo) { LOG_AND_THROW("Cannot retrieve ModelObject at objectIndex = " << objectIndex); } return *omo; }
bool LayeredConstruction_Impl::setLayer(unsigned layerIndex, const Material& material) { OS_ASSERT(material.model() == model()); layerIndex = mf_clearNullLayers(layerIndex); if (layerIndex >= numLayers()) { LOG(Info,"Asked to change the Material at layer " << layerIndex << " in " << briefDescription() << ", but there are only " << numLayers() << " layers."); return false; } MaterialVector layers = this->layers(); layers[layerIndex] = material; if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(layers)) { ModelExtensibleGroup group = getExtensibleGroup(layerIndex).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); bool ok = group.setPointer(0,material.handle()); OS_ASSERT(ok); return true; } return false; }