Пример #1
0
/**
 * @brief Adds a person to the database.
 * Should not be called directly.
 *
 * @param People
 * @return bool
 */
bool DatabaseManager::insertNewPeople(People &people)
{
    QSqlQuery l_query(m_db);
    // If a people with the same name exist, we update it
    // else we insert
    if(existPeople(people.name())) {
        Macaw::DEBUG("[DatabaseManager.insertNewPeople] Name already known");
        People l_peopleToUpdate = getOnePeopleByName(people.name());
        people.setId(l_peopleToUpdate.id());
        if(!updatePeople(people)) {

            return false;
        }
    } else {
        l_query.prepare("INSERT INTO people ("
                                                "name, "
                                                "birthday, "
                                                "biography, "
                                                "imported, "
                                                "id_tmdb "
                                            ") VALUES ("
                                                ":name, "
                                                ":birthday, "
                                                ":biography, "
                                                ":imported, "
                                                ":id_tmdb "
                                            ")"
                        );
        l_query.bindValue(":name", people.name());
        l_query.bindValue(":birthday", people.birthday().toString(DATE_FORMAT));
        l_query.bindValue(":biography", people.biography());
        l_query.bindValue(":imported", people.isImported());
        l_query.bindValue(":id_tmdb", people.tmdbId());

        if (!l_query.exec()) {
            Macaw::DEBUG("In insertNewPeople():");
            Macaw::DEBUG(l_query.lastError().text());

            return false;
        }
        people.setId(l_query.lastInsertId().toInt());
    }

    return true;
}
Пример #2
0
bool People::operator== (const People &other)
{
    if ( this->id() == other.id() &&
         this->name() == other.name() &&
         this->birthday() == other.birthday() &&
         this->biography() == other.biography() &&
         this->type() == other.type() )
    {
        return true;
    }

    return false;
}
boost::optional<IdfObject> ForwardTranslator::translatePeople( People & modelObject )
{
  IdfObject idfObject(openstudio::IddObjectType::People);
  m_idfObjects.push_back(idfObject);

  for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()){
    translateAndMapModelObject(lifeCycleCost);
  }

  PeopleDefinition definition = modelObject.peopleDefinition();

  idfObject.setString(PeopleFields::Name, modelObject.name().get());

  boost::optional<Space> space = modelObject.space();
  boost::optional<SpaceType> spaceType = modelObject.spaceType();
  if (space){
    boost::optional<ThermalZone> thermalZone = space->thermalZone();
    if (thermalZone){
      idfObject.setString(PeopleFields::ZoneorZoneListName, thermalZone->name().get());
    }
  }else if(spaceType){
    idfObject.setString(PeopleFields::ZoneorZoneListName, spaceType->name().get());
  }

  boost::optional<Schedule> schedule = modelObject.numberofPeopleSchedule();
  if (schedule){
    idfObject.setString(PeopleFields::NumberofPeopleScheduleName, schedule->name().get());
  }

  idfObject.setString(PeopleFields::NumberofPeopleCalculationMethod, definition.numberofPeopleCalculationMethod());

  double multiplier = modelObject.multiplier();

  OptionalDouble d = definition.numberofPeople();
  if (d){
    idfObject.setDouble(PeopleFields::NumberofPeople, (*d)*multiplier);
  }

  d = definition.peopleperSpaceFloorArea();
  if (d){
    idfObject.setDouble(PeopleFields::PeopleperZoneFloorArea, (*d)*multiplier);
  }

  d = definition.spaceFloorAreaperPerson();
  if (d){
    idfObject.setDouble(PeopleFields::ZoneFloorAreaperPerson, (*d)*multiplier);
  }

  d = definition.fractionRadiant();
  if (d){
    idfObject.setDouble(PeopleFields::FractionRadiant, *d);
  }

  d = definition.sensibleHeatFraction();
  if (d){
    idfObject.setDouble(PeopleFields::SensibleHeatFraction, *d);
  }

  schedule = modelObject.activityLevelSchedule();
  if (schedule){
    idfObject.setString(PeopleFields::ActivityLevelScheduleName, schedule->name().get());
  }

  if (!definition.isCarbonDioxideGenerationRateDefaulted()){
    idfObject.setDouble(PeopleFields::CarbonDioxideGenerationRate, definition.carbonDioxideGenerationRate());
  }

  if (!definition.isEnableASHRAE55ComfortWarningsDefaulted()){
    if (definition.enableASHRAE55ComfortWarnings()){
      idfObject.setString(PeopleFields::EnableASHRAE55ComfortWarnings, "Yes");
    }else{
       idfObject.setString(PeopleFields::EnableASHRAE55ComfortWarnings, "No");
    }
  }

  if (!definition.isMeanRadiantTemperatureCalculationTypeDefaulted()){
    idfObject.setString(PeopleFields::MeanRadiantTemperatureCalculationType, definition.meanRadiantTemperatureCalculationType());
  }

  // TODO: Surface Name/Angle Factor List Name

  schedule = modelObject.workEfficiencySchedule();
  if (schedule){
    idfObject.setString(PeopleFields::WorkEfficiencyScheduleName, schedule->name().get());
  }

  schedule = modelObject.clothingInsulationSchedule();
  if (schedule){
    idfObject.setString(PeopleFields::ClothingInsulationScheduleName, schedule->name().get());
  }

  schedule = modelObject.airVelocitySchedule();
  if (schedule){
    idfObject.setString(PeopleFields::AirVelocityScheduleName, schedule->name().get());
  }

  for (int i = 0, n = definition.numThermalComfortModelTypes(); i < n; ++i) {
    OptionalString s = definition.getThermalComfortModelType(i);
    if (s) {
      idfObject.pushExtensibleGroup(StringVector(1u,*s));
    }
  }

  return idfObject;
}