bool AvailabilityManagerAssignmentList_Impl::removeAvailabilityManager(const unsigned priority) {

    std::vector<AvailabilityManager> avmVector = availabilityManagers();

    if( (priority > avmVector.size() ) || ( priority < 1 ) ) {
      LOG(Warn, "Priority of '" << priority << " is out of bounds for " << briefDescription());
      return false;
    }

     // Clear the extensible groups, and redo them
    clearExtensibleGroups();
    // priority starts at one

    unsigned i = 1;
    bool result = false;

    for (const AvailabilityManager& a : avmVector) {
      if (i == priority) {
        result = true;
      } else {
        bool ok = addAvailabilityManager(a);
        OS_ASSERT(ok);
      }
      ++i;
    }
    return result;
  }
 bool AvailabilityManagerAssignmentList_Impl::setAvailabilityManagers(const std::vector<AvailabilityManager> & avms) {
   // Clear the extensible groups, and redo them
   clearExtensibleGroups();
   for (const AvailabilityManager& a: avms) {
     bool ok = addAvailabilityManager(a);
     OS_ASSERT(ok);
   }
   return true;
 }
  bool MaterialPropertyGlazingSpectralData_Impl::setSpectralDataFields(const std::vector<SpectralDataField>& spectralDataFields)
  {
    std::vector<SpectralDataField> originalFields = this->spectralDataFields();

    bool result = true;

    clearExtensibleGroups(false);
    for (const auto& spectralDataField : spectralDataFields) {
      result = result && addSpectralDataField(spectralDataField);
    }

    if (!result){
      clearExtensibleGroups(false);
      for (const auto& spectralDataField : originalFields) {
        addSpectralDataField(spectralDataField);
      }
    }

    return result;
  }
예제 #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);
     }
  bool AvailabilityManagerAssignmentList_Impl::removeAvailabilityManager(const AvailabilityManager& avm) {

    std::vector<AvailabilityManager> avmVector = availabilityManagers();

    OS_ASSERT( std::find(avmVector.begin(),avmVector.end(), avm) != avmVector.end() );

    avmVector.erase(std::find(avmVector.begin(),avmVector.end(),avm));

    // Clear the extensible groups, and redo them
    clearExtensibleGroups();
    for (const AvailabilityManager& a : avmVector) {
      bool ok = addAvailabilityManager(a);
      OS_ASSERT(ok);
    }
    return true;
  }
  bool AvailabilityManagerAssignmentList_Impl::setAvailabilityManagerPriority(const AvailabilityManager & avm, unsigned priority)
  {
    std::vector<AvailabilityManager> avmVector = availabilityManagers();

    OS_ASSERT( std::find(avmVector.begin(),avmVector.end(), avm) != avmVector.end() );

    if( priority > avmVector.size() ) priority = avmVector.size();
    if( priority < 1 ) priority = 1;

    avmVector.erase(std::find(avmVector.begin(),avmVector.end(),avm));

    avmVector.insert(avmVector.begin() + (priority - 1),avm);

    // Clear the extensible groups, and redo them
    clearExtensibleGroups();
    for (const AvailabilityManager& a : avmVector) {
      bool ok = addAvailabilityManager(a);
      OS_ASSERT(ok);
    }
    return true;
  }
  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;
  }
 void MaterialPropertyGlazingSpectralData_Impl::resetSpectralDataFields()
 {
   clearExtensibleGroups(false);
 }
  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;
  }
예제 #10
0
 bool ClimateZones_Impl::clear() {
   clearExtensibleGroups();
   return (numExtensibleGroups() == 0u);
 }
 void AvailabilityManagerAssignmentList_Impl::resetAvailabilityManagers() {
   clearExtensibleGroups();
 }
 void EnergyManagementSystemProgramCallingManager_Impl::erasePrograms() {
   //erase all programs in this calling manager
   clearExtensibleGroups();
 }