Files ModelToRadPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm")) || !m_osm) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.osm"), "osm"); fi.requiredFiles = m_osm->requiredFiles; if (!fi.hasRequiredFile(openstudio::toPath("in.epw"))) { /// \todo we need better handling of OSM files and their attachments // epw wasn't found, look for parent one openstudio::path possibleepw = m_osm->fullPath.parent_path() / openstudio::toPath("in.epw"); if (boost::filesystem::exists(possibleepw)) { LOG(Info, "Fixing up EPW file for incoming OSM attachment to " << openstudio::toString(possibleepw)); fi.addRequiredFile(possibleepw, openstudio::toPath("in.epw")); } } f.append(fi); return f; }
Job JobFactory::createEnergyPlusJob( ToolInfo t_energyPlusTool, const openstudio::path &t_idd, const openstudio::path &t_idf, const openstudio::path &t_epw, const openstudio::path &t_outdir, const boost::optional<openstudio::UUID> &t_uuid) { JobParams params; params.append("outdir", toString(t_outdir)); Tools tools; t_energyPlusTool.name = "energyplus"; tools.append(t_energyPlusTool); Files files; FileInfo idf(t_idf, "idf"); if (!t_idd.empty()) { idf.addRequiredFile(t_idd,toPath("Energy+.idd")); } idf.addRequiredFile(t_epw, toPath("in.epw")); files.append(idf); return createEnergyPlusJob(tools, params, files, std::vector<openstudio::URLSearchPath>(), t_uuid); }
TEST_F(RunManagerTestFixture, Workflow_ToWorkItems) { ToolInfo ti("tool", openstudio::toPath("somepath")); Tools tis; tis.append(ti); JobParam param("param1"); JobParams params; params.append(param); FileInfo fi(openstudio::toPath("somefile.txt"), "txt"); Files fis; fis.append(fi); Workflow wf("null->energyplus"); wf.add(params); wf.add(tis); wf.add(fis); std::vector<WorkItem> wis = wf.toWorkItems(); ASSERT_EQ(2u, wis.size()); EXPECT_EQ(JobType(JobType::Null), wis[0].type); EXPECT_EQ(JobType(JobType::EnergyPlus), wis[1].type); EXPECT_EQ(params, wis[0].params); EXPECT_EQ(fis, wis[0].files); EXPECT_EQ(tis, wis[0].tools); EXPECT_TRUE(wis[1].params.params().empty()); EXPECT_TRUE(wis[1].files.files().empty()); EXPECT_TRUE(wis[1].tools.tools().empty()); }
Job JobFactory::createEnergyPlusJob( const openstudio::runmanager::Tools &t_tools, const openstudio::path &t_idd, const openstudio::path &t_idf, const openstudio::path &t_epw, const openstudio::path &t_outdir, const boost::optional<openstudio::UUID> &t_uuid) { JobParams params; params.append("outdir", toString(t_outdir)); Files files; FileInfo idf(t_idf, "idf"); if (!t_idd.empty()) { idf.addRequiredFile(t_idd,toPath("Energy+.idd")); } if (boost::filesystem::is_directory(t_epw)) { params.append("epwdir", toString(t_epw)); } else { idf.addRequiredFile(t_epw, toPath("in.epw")); } files.append(idf); return createEnergyPlusJob(t_tools, params, files, std::vector<openstudio::URLSearchPath>(), t_uuid); }
Files BasementJob::outputFilesHandlerImpl() const { FileInfo fi(outdir() / openstudio::toPath("basementmerged.idf"), "idf"); fi.requiredFiles = m_expandedidf->requiredFiles; Files f; f.append(fi); return f; }
Files OpenStudioPostProcessJob::outputFilesImpl() const { // Dan: what's the output files generated? if (!boost::filesystem::exists(outdir() / toPath("report.xml"))) { // no output file has been generated yet return Files(); } Files f; f.append(FileInfo(outdir() / toPath("report.xml"), "xml")); return f; }
Job JobFactory::createIdfToModelJob( const openstudio::path &t_idf, const openstudio::path &t_outdir, const boost::optional<openstudio::UUID> &t_uuid) { JobParams params; params.append("outdir", toString(t_outdir)); Files files; files.append(FileInfo(t_idf, "idf")); return createIdfToModelJob(Tools(), params, files, std::vector<openstudio::URLSearchPath>(), t_uuid); }
Files ModelInModelOutJob::outputFilesImpl() const { Files outfiles; try { FileInfo osm(outdir() / toPath("out.osm"), "osm"); osm.requiredFiles = modelFile().requiredFiles; outfiles.append(osm); } catch (const std::exception &) { //output file cannot be generated yet } return outfiles; }
Files ModelToRadPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm")) || !m_osm) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.osm"), "osm"); fi.requiredFiles = m_osm->requiredFiles; f.append(fi); return f; }
Files IdfToModelJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm"))) { // no output file has been generated yet return Files(); } QWriteLocker l(&m_mutex); if (!m_outputfiles) { // check if model has a weather file object boost::optional<QUrl> weatherFilePath; try { FileInfo idfFile = this->idfFile(); try { std::pair<QUrl, openstudio::path> f = idfFile.getRequiredFile(toPath("in.epw")); LOG(Debug, "Setting user defined epw: " << toString(f.first.toString())); weatherFilePath = f.first; } catch (const std::exception &) { } // Specify the set of files we created so that the next Job in the chain (if there is one) // is able to pick them up Files outfiles; FileInfo osm(outpath / toPath("out.osm"), "osm"); if (weatherFilePath){ osm.addRequiredFile(*weatherFilePath, toPath("in.epw")); }else{ LOG(Warn, "No weather file specified"); } outfiles.append(osm); m_outputfiles = outfiles; } catch (const std::exception &) { LOG(Warn, "OSM file not yet available, outputfiles not known"); return Files(); } } return *m_outputfiles; }
Job JobFactory::createRubyJob( const openstudio::runmanager::RubyJobBuilder &t_builder, const std::vector<openstudio::URLSearchPath> &t_url_search_paths, bool t_loading, const boost::optional<openstudio::UUID> &t_uuid) { Files files; openstudio::path scriptPath = t_builder.script(); if (!scriptPath.empty()) { openstudio::runmanager::FileInfo fi(scriptPath,"rb"); BOOST_FOREACH(const PathPair& reqFile,t_builder.requiredFiles()) { fi.addRequiredFile(reqFile.first,reqFile.second); } files.append(fi); }
Job JobFactory::createRubyJob( const openstudio::path &t_rubyfile, const std::string &t_infileregex, const openstudio::path &t_outdir, const boost::optional<openstudio::UUID> &t_uuid) { JobParams params; params.append("outdir", toString(t_outdir)); params.append("input_file_regex", t_infileregex); Files files; files.append(FileInfo(t_rubyfile, "rb")); return createRubyJob(Tools(), params, files, std::vector<openstudio::URLSearchPath>(), t_uuid); }
Files EnergyPlusPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.idf"))) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.idf"), "idf"); if (m_idf) { fi.requiredFiles = m_idf->requiredFiles; } f.append(fi); return f; }
TEST_F(RunManagerTestFixture, Workflow_FromWorkItems) { ToolInfo ti("tool", openstudio::toPath("somepath")); Tools tis; tis.append(ti); JobParam param("param1"); JobParams params; params.append(param); FileInfo fi(openstudio::toPath("somefile.txt"), "txt"); Files fis; fis.append(fi); std::vector<WorkItem> wi; wi.push_back(WorkItem(JobType::Null, tis, params, fis)); wi.push_back(WorkItem(JobType::EnergyPlus)); Workflow wf(wi); EXPECT_EQ(tis, wf.tools()); EXPECT_EQ(params, wf.params()); EXPECT_EQ(fis, wf.files()); }
Files ParallelEnergyPlusSplitJob::outputFilesImpl() const { // Save off the set of requiredfiles, see below std::vector<std::pair<QUrl, openstudio::path> > requiredFiles = inputFile().requiredFiles; std::vector<openstudio::path> files = generateFileNames(outdir(), m_numSplits); Files retval; for (std::vector<openstudio::path>::const_iterator itr = files.begin(); itr != files.end(); ++itr) { if (boost::filesystem::exists(*itr)) { FileInfo fi = RunManager_Util::dirFile(*itr); // we want to carry along the set of required files used in the original IDF to the children // (ie, the epw file) fi.requiredFiles = requiredFiles; retval.append(fi); } } return retval; }
void ModelToRadJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { if (!m_model) { m_model = modelFile(); } if (!m_sql) { m_sql = sqlFile(); } resetFiles(m_files, m_model); } catch (const std::runtime_error &e) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, e.what()); } if (!m_sql || !m_model) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "Unable to find required model or sql file"); } LOG(Info, "ModelToRad starting, filename: " << toString(m_model->fullPath)); LOG(Info, "ModelToRad starting, outdir: " << toString(outpath)); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { boost::filesystem::create_directories(outpath); // // setup // LOG(Debug, "Working Directory: " + openstudio::toString(outpath)); // get model boost::optional<openstudio::IdfFile> idf = openstudio::IdfFile::load(m_model->fullPath); openstudio::model::Model model = openstudio::model::Model(idf.get()); // load the sql file openstudio::SqlFile sqlFile(m_sql->fullPath); if (!sqlFile.connectionOpen()) { LOG(Error, "SqlFile connection is not open"); errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "SqlFile collection is not open"); setErrors(errors); return; } // set the sql file model.setSqlFile(sqlFile); if (!model.sqlFile()) { LOG(Error, "SqlFile is not set on model"); errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "SqlFile is not set on model"); setErrors(errors); return; } openstudio::radiance::ForwardTranslator ft; std::vector<openstudio::path> outfiles = ft.translateModel(outpath, model); // capture translator errors and warnings? //ft.errors(); //ft.warnings(); Files outfileinfos; for (std::vector<openstudio::path>::const_iterator itr = outfiles.begin(); itr != outfiles.end(); ++itr) { FileInfo fi = RunManager_Util::dirFile(*itr); LOG(Info, "Output file generated: " << openstudio::toString(fi.fullPath)); emitOutputFileChanged(fi); outfileinfos.append(fi); } l.relock(); m_outputfiles = outfileinfos; /// Do work here - and be sure to set output files too } catch (const std::runtime_error &e) { errors.addError(ErrorType::Error, "Error with conversion (runtime_error): " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } catch (const std::exception &e) { errors.addError(ErrorType::Error, "Error with conversion: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } setErrors(errors); }