void SiteWaterMainsTemperature_Impl::populateValidityReport(ValidityReport& report,bool checkNames) const {
    // Inherit lower-level errors
    ModelObject_Impl::populateValidityReport(report,checkNames);

    if (report.level() > StrictnessLevel::Draft) {
        boost::optional<IddKey> key = iddObject().getField(OS_Site_WaterMainsTemperatureFields::CalculationMethod).get().getKey(calculationMethod());
        OS_ASSERT(key);
        if (key->name() == "Schedule") {
            if (!temperatureSchedule()) {
                report.insertError(DataError(OS_Site_WaterMainsTemperatureFields::TemperatureScheduleName,
                                             getObject<ModelObject>(),
                                             DataErrorType::NullAndRequired));
            }
        }
        else {
            // Correlation
            if (!annualAverageOutdoorAirTemperature()) {
                report.insertError(DataError(OS_Site_WaterMainsTemperatureFields::AnnualAverageOutdoorAirTemperature,
                                             getObject<ModelObject>(),
                                             DataErrorType::NullAndRequired));
            }
            if (!maximumDifferenceInMonthlyAverageOutdoorAirTemperatures()) {
                report.insertError(DataError(OS_Site_WaterMainsTemperatureFields::MaximumDifferenceInMonthlyAverageOutdoorAirTemperatures,
                                             getObject<ModelObject>(),
                                             DataErrorType::NullAndRequired));
            }
        }
    }
}
예제 #2
0
  void GasMixture_Impl::populateValidityReport(ValidityReport& report,bool checkNames) const {
    // Inherit lower-level errors
    ModelObject_Impl::populateValidityReport(report,checkNames);

    if (report.level() == StrictnessLevel::Final) {
      // all gases must be defined
      for (unsigned i = 0, n = numGases(); i < n; ++i) {
        try {
          std::string type = getGasType(i);
        }
        catch (...) {
          report.insertError(DataError(mf_getGasTypeFieldIndex(i),
                                       getObject<GasMixture>(),
                                       DataErrorType::NullAndRequired));
        }
        try {
          /* double fraction =*/ getGasFraction(i);
        }
        catch (...) {
          report.insertError(DataError(mf_getGasFractionFieldIndex(i),
                                       getObject<GasMixture>(),
                                       DataErrorType::NullAndRequired));
        }
      }
    }
  }
예제 #3
0
TEST_F(ModelFixture, Schedule_FinalStrictness) {
  Model model;
  ScheduleConstant schedule(model);
  schedule.setValue(-0.1);
  EXPECT_TRUE(checkOrAssignScheduleTypeLimits("Lights","Lighting",schedule));
  ValidityReport report = schedule.validityReport(StrictnessLevel(StrictnessLevel::Final));
  ASSERT_EQ(0u,report.numErrors());
  schedule.setValue(0.5);
  report = schedule.validityReport(StrictnessLevel(StrictnessLevel::Final));
  EXPECT_EQ(0u,report.numErrors());
}
예제 #4
0
TEST_F(ModelFixture, Schedule_FinalStrictness) {
  Model model;
  ScheduleConstant schedule(model);
  schedule.setValue(-0.1);
  EXPECT_TRUE(checkOrAssignScheduleTypeLimits("Lights","Lighting",schedule));
  ValidityReport report = schedule.validityReport(StrictnessLevel(StrictnessLevel::Final));
  ASSERT_EQ(1u,report.numErrors());
  DataError error = report.nextError().get();
  EXPECT_EQ(DataErrorType(DataErrorType::NumericBound),error.type());
  schedule.setValue(0.5);
  report = schedule.validityReport(StrictnessLevel(StrictnessLevel::Final));
  EXPECT_EQ(0u,report.numErrors());
}
예제 #5
0
TEST_F(IdfFixture, IdfFile_BasicTests_LoadedFile)
{
  // as loaded
  EXPECT_TRUE(epIdfFile.objects().size() > 0);
  LOG(Info,"Checking validity of epIdfFile.");
  ValidityReport report = epIdfFile.validityReport(StrictnessLevel::Final);
  EXPECT_EQ(static_cast<unsigned>(0),report.numErrors());
  if (report.numErrors() > 0) {
    LOG(Error,"epIdfFile is not valid at Strictness Final. The ValidityReport follows." 
        << std::endl << report);
  }

  // write out as Idf for diff
  openstudio::path outPath = outDir/toPath("RoundTrip_in.idf");
  openstudio::Time start = openstudio::Time::currentTime();
  epIdfFile.save(outPath,true);
  openstudio::Time writeTime = openstudio::Time::currentTime() - start;
  LOG(Info, "IdfFile written to idf text in " << writeTime << "s. Please check diff by hand.");
}