/// @cond ClimateZones::ClimateZones(Model& model) : ModelObject(ClimateZones::iddObjectType(),model) { // add empty climate zone to define default institution pushExtensibleGroup(StringVector()); // Programming note: This line of code cannot be in the _Impl constructor because // pushExtensibleGroup constructs an IdfExtensibleGroup from the _Impl. }
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; }
bool MaterialPropertyGlazingSpectralData_Impl::addSpectralDataField(const SpectralDataField& spectralDataField) { std::vector<std::string> values; values.push_back(toString(spectralDataField.wavelength())); values.push_back(toString(spectralDataField.transmittance())); values.push_back(toString(spectralDataField.frontReflectance())); values.push_back(toString(spectralDataField.backReflectance())); ModelExtensibleGroup group = pushExtensibleGroup(values, false).cast<ModelExtensibleGroup>(); return (!group.empty()); }
bool LayeredConstruction_Impl::setLayers(const std::vector<Material>& materials) { if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(materials)) { clearExtensibleGroups(); BOOST_FOREACH(const Material& material, materials) { OS_ASSERT(material.model() == model()); ModelExtensibleGroup group = pushExtensibleGroup(StringVector()).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); bool ok = group.setPointer(0,material.handle()); OS_ASSERT(ok); }
ClimateZone ClimateZones_Impl::appendClimateZone(const std::string& institution, const std::string documentName, unsigned year, const std::string& value) { StringVector values; values.push_back(institution); values.push_back(documentName); std::stringstream ss; ss << year; values.push_back(ss.str()); values.push_back(value); IdfExtensibleGroup eg = pushExtensibleGroup(values); if (eg.empty()) { std::shared_ptr<ClimateZones_Impl> p; return ClimateZone(p,numFields()); } return eg.cast<ClimateZone>(); }
bool ScheduleVariableInterval_Impl::setTimeSeries(const openstudio::TimeSeries& timeSeries) { clearExtensibleGroups(false); DateTime firstReportDateTime = timeSeries.firstReportDateTime(); Date startDate = firstReportDateTime.date(); // set the start date this->setStartMonth(startDate.monthOfYear().value(), false); this->setStartDay(startDate.dayOfMonth(), false); // set the out of range value double outOfRangeValue = timeSeries.outOfRangeValue(); this->setOutOfRangeValue(outOfRangeValue); // set the values std::vector<long> secondsFromFirstReport = timeSeries.secondsFromFirstReport(); openstudio::Vector values = timeSeries.values(); for (unsigned i = 0; i < values.size(); ++i){ DateTime dateTime = firstReportDateTime + Time(0,0,0,secondsFromFirstReport[i]); Date date = dateTime.date(); Time time = dateTime.time(); std::vector<std::string> temp; temp.push_back(boost::lexical_cast<std::string>(date.monthOfYear().value())); temp.push_back(boost::lexical_cast<std::string>(date.dayOfMonth())); temp.push_back(boost::lexical_cast<std::string>(time.hours())); temp.push_back(boost::lexical_cast<std::string>(time.minutes())); temp.push_back(toString(values[i])); ModelExtensibleGroup group = pushExtensibleGroup(temp, false).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); } this->emitChangeSignals(); return true; }
bool ScheduleRule_Impl::addSpecificDate(const openstudio::Date& date) { bool result = setString(OS_Schedule_RuleFields::DateSpecificationType, "SpecificDates", false); OS_ASSERT(result); result = setString(OS_Schedule_RuleFields::StartMonth, "", false); OS_ASSERT(result); result = setString(OS_Schedule_RuleFields::StartDay, "", false); OS_ASSERT(result); result = setString(OS_Schedule_RuleFields::EndMonth, "", false); OS_ASSERT(result); result = setString(OS_Schedule_RuleFields::EndDay, "", false); OS_ASSERT(result); std::vector<std::string> values; values.push_back(boost::lexical_cast<std::string>(date.monthOfYear().value())); values.push_back(boost::lexical_cast<std::string>(date.dayOfMonth())); ModelExtensibleGroup group = pushExtensibleGroup(values, true).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); return true; }
bool ScheduleYear_Impl::addScheduleWeek(const openstudio::Date& untilDate, const ScheduleWeek& scheduleWeek) { YearDescription yd = this->model().getUniqueModelObject<YearDescription>(); if (yd.assumedYear() != untilDate.assumedBaseYear()){ LOG(Error, "Assumed base year " << untilDate.assumedBaseYear() << " of untilDate does not match this model's assumed base year of " << yd.assumedYear()); return false; } std::vector<ScheduleWeek> scheduleWeeks = this->scheduleWeeks(); // these are already sorted std::vector<openstudio::Date> dates = this->dates(); // these are already sorted bool inserted = false; unsigned N = dates.size(); OS_ASSERT(scheduleWeeks.size() == N); this->clearExtensibleGroups(); for (unsigned i = 0; i < N; ++i){ if (dates[i] == untilDate){ bool doEmit = (i == (N-1)); // push back just this schedule/date pair std::vector<std::string> groupValues; groupValues.push_back(boost::lexical_cast<std::string>(untilDate.monthOfYear().value())); groupValues.push_back(boost::lexical_cast<std::string>(untilDate.dayOfMonth())); groupValues.push_back(scheduleWeek.name().get()); ModelExtensibleGroup group = pushExtensibleGroup(groupValues, doEmit).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); inserted = true; }else{ // if we need to insert new schedule/date pair here if ((untilDate < dates[i]) && !inserted){ // push back this schedule/date pair std::vector<std::string> groupValues; groupValues.push_back(boost::lexical_cast<std::string>(untilDate.monthOfYear().value())); groupValues.push_back(boost::lexical_cast<std::string>(untilDate.dayOfMonth())); groupValues.push_back(scheduleWeek.name().get()); ModelExtensibleGroup group = pushExtensibleGroup(groupValues, false).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); inserted = true; } bool doEmit = (i == (N-1)) && inserted; // insert existing schedule/date pair std::vector<std::string> groupValues; groupValues.push_back(boost::lexical_cast<std::string>(dates[i].monthOfYear().value())); groupValues.push_back(boost::lexical_cast<std::string>(dates[i].dayOfMonth())); groupValues.push_back(scheduleWeeks[i].name().get()); ModelExtensibleGroup group = pushExtensibleGroup(groupValues, doEmit).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); } } if (!inserted){ // push back this schedule/date pair std::vector<std::string> groupValues; groupValues.push_back(boost::lexical_cast<std::string>(untilDate.monthOfYear().value())); groupValues.push_back(boost::lexical_cast<std::string>(untilDate.dayOfMonth())); groupValues.push_back(scheduleWeek.name().get()); ModelExtensibleGroup group = pushExtensibleGroup(groupValues, true).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); } return true; }
bool PeopleDefinition_Impl::pushThermalComfortModelType( const std::string& thermalComfortModelType) { return !pushExtensibleGroup(StringVector(1u,thermalComfortModelType)).empty(); }
bool ScheduleFixedInterval_Impl::setTimeSeries(const openstudio::TimeSeries& timeSeries) { // check the interval boost::optional<openstudio::Time> intervalTime = timeSeries.intervalLength(); if (!intervalTime){ return false; } // check the interval double intervalLength = intervalTime->totalMinutes(); if (intervalLength - floor(intervalLength) > 0){ return false; } // check the interval if (intervalTime->totalDays() > 1){ return false; } // check that first report is whole number of intervals from start date DateTime firstReportDateTime = timeSeries.firstReportDateTime(); Date startDate = firstReportDateTime.date(); Time firstReportTime = firstReportDateTime.time(); double numIntervalsToFirstReport = std::max(1.0, firstReportTime.totalMinutes() / intervalLength); if (numIntervalsToFirstReport - floor(numIntervalsToFirstReport) > 0){ return false; } // at this point we are going to change the object clearExtensibleGroups(false); // set the interval this->setIntervalLength(intervalLength, false); // set the start date this->setStartMonth(startDate.monthOfYear().value(), false); this->setStartDay(startDate.dayOfMonth(), false); // set the out of range value double outOfRangeValue = timeSeries.outOfRangeValue(); // add in numIntervalsToFirstReport-1 outOfRangeValues to pad the timeseries for (unsigned i = 0; i < numIntervalsToFirstReport - 1; ++i){ std::vector<std::string> temp; temp.push_back(toString(outOfRangeValue)); ModelExtensibleGroup group = pushExtensibleGroup(temp, false).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); } // set the values openstudio::Vector values = timeSeries.values(); for (unsigned i = 0; i < values.size(); ++i){ std::vector<std::string> temp; temp.push_back(toString(values[i])); ModelExtensibleGroup group = pushExtensibleGroup(temp, false).cast<ModelExtensibleGroup>(); OS_ASSERT(!group.empty()); } this->emitChangeSignals(); return true; }