コード例 #1
0
  bool LayeredConstruction_Impl::insertLayer(unsigned layerIndex, 
                                             const Material& material) 
  {
    OS_ASSERT(material.model() == model());
    layerIndex = mf_clearNullLayers(layerIndex);

    unsigned n = numLayers();
    MaterialVector layers = this->layers();
    MaterialVector::iterator layersBegin = layers.begin();
    MaterialVector::iterator layersEnd = layers.end();
    MaterialVector::iterator insertAtIt = layersBegin;
    while ((static_cast<unsigned>(insertAtIt - layersBegin) < layerIndex) &&
           (insertAtIt != layersEnd)) 
    { ++insertAtIt; }
    layers.insert(insertAtIt, material);
    OS_ASSERT(layers.size() == ++n);
    if ((model().strictnessLevel() < StrictnessLevel::Final) || 
        LayeredConstruction::layersAreValid(layers)) 
    {
      IdfExtensibleGroup idfGroup = insertExtensibleGroup(layerIndex,StringVector());
      OS_ASSERT(!idfGroup.empty());
      ModelExtensibleGroup group = idfGroup.cast<ModelExtensibleGroup>();
      bool ok = group.setPointer(0,material.handle());
      OS_ASSERT(ok);
      return true;
    }

    return false;
  }
コード例 #2
0
ファイル: ComponentData.cpp プロジェクト: jtanaa/OpenStudio
 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;
 }
コード例 #3
0
  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());
  }
コード例 #4
0
 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);
     }
コード例 #5
0
 std::vector<Glazing> ThermochromicGlazing_Impl::mf_glazings() const {
   GlazingVector result;
   for (const IdfExtensibleGroup& idfGroup : extensibleGroups()) {
     ModelExtensibleGroup group = idfGroup.cast<ModelExtensibleGroup>();
     OptionalWorkspaceObject owo = group.getTarget(OS_WindowMaterial_GlazingGroup_ThermochromicExtensibleFields::WindowMaterialGlazingName);
     if (owo) {
       OptionalGlazing og = owo->optionalCast<Glazing>();
       OS_ASSERT(og);
       result.push_back(*og);
     }
   }
   return result;
 }
 bool EnergyManagementSystemProgramCallingManager_Impl::setProgram(const EnergyManagementSystemProgram& program, unsigned index) {
   //add program to {index} of vector of programs
   bool result = false;
   auto groups = extensibleGroups();
   unsigned sizeOfGroup = numExtensibleGroups();
   if (index <= sizeOfGroup) {
     IdfExtensibleGroup idfGroup = insertExtensibleGroup(index, StringVector());
     OS_ASSERT(!idfGroup.empty());
     ModelExtensibleGroup group = idfGroup.cast<ModelExtensibleGroup>();
     result = group.setPointer(0, program.handle());
   }
   return result;
 }
コード例 #7
0
  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;
  }
コード例 #8
0
ファイル: ScheduleRule.cpp プロジェクト: Anto-F/OpenStudio
  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;
  }
コード例 #9
0
  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;
  }
コード例 #10
0
  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;
  }
コード例 #11
0
  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;
  }