Beispiel #1
0
  boost::optional<std::pair<ToolVersion, ToolLocationInfo> > AddTool::getTool()
  {
    openstudio::path localpath = toPath(ui.txtToolLocation->text());

    int major = ui.sbMajorVersionNumber->value();
    int minor = ui.sbMinorVersionNumber->value();
    int build = ui.sbBuildVersionNumber->value();

    if (major > -1)
    {
      if (minor > -1)
      {
        if (build > -1)
        {
          return std::make_pair(ToolVersion(major, minor, build), 
              ToolLocationInfo(ToolType(toString(ui.cbToolType->currentText())), localpath));
        } else {
          return std::make_pair(ToolVersion(major, minor), 
              ToolLocationInfo(ToolType(toString(ui.cbToolType->currentText())), localpath));
        }
      } else {
        return std::make_pair(ToolVersion(major), 
            ToolLocationInfo(ToolType(toString(ui.cbToolType->currentText())), localpath));
      }
    } else {
      return std::make_pair(ToolVersion(), 
          ToolLocationInfo(ToolType(toString(ui.cbToolType->currentText())), localpath));
    }

  }
  void WeatherFileFinder::extractDetails(
      const IdfFile &t_idffile,
      ToolVersion &t_version,
      boost::optional<std::string> &t_filelocationname,
      boost::optional<std::string> &t_weatherfilename)
  {
    IdfObjectVector versionObjects = t_idffile.getObjectsByType(IddObjectType::Version);
    if(versionObjects.size() == 1){
      OptionalString version = versionObjects[0].getString(VersionFields::VersionIdentifier, true);
      if (version){
        boost::regex majorMinorBuildRegex("^(\\d*?)\\.(\\d*?)\\.(\\d*?)$");
        boost::regex majorMinorRegex("^(\\d*?)\\.(\\d*?)$");
        boost::regex majorRegex("^(\\d*?)$");

        boost::smatch matches;
        if (boost::regex_search(*version, matches, majorMinorBuildRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          unsigned minor = boost::lexical_cast<unsigned>(std::string(matches[2].first, matches[2].second));
          unsigned build = boost::lexical_cast<unsigned>(std::string(matches[3].first, matches[3].second));
          t_version = ToolVersion(major, minor, build);
        }else if(boost::regex_search(*version, matches, majorMinorRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          unsigned minor = boost::lexical_cast<unsigned>(std::string(matches[2].first, matches[2].second));
          t_version = ToolVersion(major, minor);
        }else if(boost::regex_search(*version, matches, majorRegex)){
          unsigned major = boost::lexical_cast<unsigned>(std::string(matches[1].first, matches[1].second));
          t_version = ToolVersion(major);
        }
      }
    }

    IdfObjectVector locationObjects = t_idffile.getObjectsByType(IddObjectType::Site_Location);
    if(locationObjects.size() == 1){
      OptionalString locationname = locationObjects[0].getString(Site_LocationFields::Name, true);
      if (locationname && !locationname->empty()){
        LOG(Debug, "Location name field from IDF: " << *locationname);
        t_filelocationname = locationname;
      }
    }

    std::string header = t_idffile.header();
    std::vector<std::string> headerlines;
    boost::split(headerlines, header, boost::is_any_of("\n\r"), boost::algorithm::token_compress_on);
    for (std::vector<std::string>::const_iterator itr = headerlines.begin();
         itr != headerlines.end();
         ++itr)
    {
      boost::smatch matches;
     
      if (boost::regex_match(*itr, matches, boost::regex(".*!\\s+WeatherFileName=(.*)"),boost::regex_constants::match_all))
      {
        std::string match = matches[1];
        t_weatherfilename = match;
        break;
      }
    }
  }
Beispiel #3
0
  ToolVersion ToolVersion::fromString(const std::string &t_val) 
  {
    boost::optional<int> major;
    boost::optional<int> minor;
    boost::optional<int> build;

    std::vector<std::string> parts;
    boost::split(parts, t_val, boost::is_any_of("."), boost::algorithm::token_compress_on);

    if (parts.size() > 0)
    {
      major = atoi(parts[0].c_str());
    }

    if (parts.size() > 1)
    {
      minor = atoi(parts[1].c_str());
    }

    if (parts.size() > 2)
    {
      build = atoi(parts[2].c_str());
    }

    return ToolVersion(major, minor, build);
  }
Beispiel #4
0
  ToolVersion ReadVarsJob::getToolVersionImpl(const std::string &t_toolName) const
  {
    if (t_toolName != "readvars") {
      throw std::runtime_error("Invalid tool version request: " + t_toolName);
    }

    return ToolVersion();
  }
  ToolVersion XMLPreprocessorJob::getToolVersionImpl(const std::string &t_toolName) const
  {
    if (t_toolName != "xmlpreprocessor") {
      throw std::runtime_error("Invalid tool version request: " + t_toolName);
    }

    return ToolVersion();
  }
  ToolVersion PreviewIESJob::getToolVersionImpl(const std::string &t_toolName) const
  {
    std::vector<std::string> names = toolNames();
    if (std::find(names.begin(), names.end(), t_toolName) == names.end()) {
      throw std::runtime_error("Invalid tool version request: " + t_toolName);
    }

    return ToolVersion();
  }