source: src/controller_SystemCommandJob.cpp@ a10cc0

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since a10cc0 was 014bc4, checked in by Frederik Heber <heber@…>, 13 years ago

Introduced interface controller_AddOn.hpp that encapsulates controller extending functions in struct controller_AddOn.

  • allocating function for derived structure controller_AddOn is contained in extra module to allow indepent linking, i.e. combine controller.cpp, controller_AddOn_SystemCommandJob.cpp and controller_SystemCommandJon.cpp or with controller_AddOn_MPQCCommandJob.cpp and controller_MPQCCommandJon.cpp.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * controller_SystemCommandJob.cpp
10 *
11 * Created on: 01.06.2012
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "controller_SystemCommandJob.hpp"
23
24#include <boost/assign.hpp>
25#include <boost/bind.hpp>
26
27#include "FragmentController.hpp"
28#include "Jobs/SystemCommandJob.hpp"
29#include "Results/FragmentResult.hpp"
30
31#include "ControllerCommand.hpp"
32#include "ControllerCommandRegistry.hpp"
33#include "ControllerOptions_SystemCommandJob.hpp"
34
35/** Print received results.
36 *
37 * @param results received results to print
38 */
39void printReceivedResults(const std::vector<FragmentResult::ptr> &results)
40{
41 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
42 iter != results.end(); ++iter)
43 LOG(1, "RESULT: job #"+toString((*iter)->getId())+": "+toString((*iter)->result));
44}
45
46/** Creates a SystemCommandJob out of give \a command with \a argument.
47 *
48 * @param controller reference to controller to add jobs
49 * @param ControllerInfo information on the job
50 */
51void createJobs(FragmentController &controller, const ControllerOptions_SystemCommandJob &ControllerInfo)
52{
53 const JobId_t next_id = controller.getAvailableId();
54 LOG(2, "DEBUG: Creating new SystemCommandJob with '"
55 +toString(ControllerInfo.executable)+"' and argument '"
56 +toString(ControllerInfo.jobcommand)+"'.");
57 FragmentJob::ptr testJob(
58 new SystemCommandJob(ControllerInfo.executable, ControllerInfo.jobcommand, next_id) );
59 std::vector<FragmentJob::ptr> jobs;
60 jobs.push_back(testJob);
61 controller.addJobs(jobs);
62 controller.sendJobs(ControllerInfo.server, ControllerInfo.serverport);
63 LOG(1, "INFO: Added one SystemCommandJob.");
64}
65
66inline std::vector<std::string> getListOfCommands(const ControllerCommandRegistry &ControllerCommands)
67{
68 std::vector<std::string> Commands;
69 for (ControllerCommandRegistry::const_iterator iter = ControllerCommands.getBeginIter();
70 iter != ControllerCommands.getEndIter(); ++iter)
71 Commands.push_back(iter->first);
72
73 return Commands;
74}
75
76ControllerOptions *controller_SystemCommandJob::allocateControllerInfo()
77{
78 return new ControllerOptions_SystemCommandJob();
79}
80
81void controller_SystemCommandJob::addSpecificCommands(
82 boost::function<void (ControllerCommand *)> &registrator,
83 FragmentController &controller,
84 ControllerOptions &ControllerInfo)
85{
86 ControllerOptions_SystemCommandJob &CI =
87 reinterpret_cast<ControllerOptions_SystemCommandJob &>(ControllerInfo);
88 registrator(new ControllerCommand("createjobs",
89 boost::assign::list_of< ControllerCommand::commands_t >
90 (boost::bind(&FragmentController::requestIds,
91 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 1))
92 (boost::bind(&createJobs, boost::ref(controller), boost::cref(CI)))
93 ));
94 registrator(new ControllerCommand("receiveresults",
95 boost::assign::list_of< ControllerCommand::commands_t >
96 (boost::bind(&FragmentController::receiveResults,
97 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
98 (boost::bind(&printReceivedResults,
99 boost::bind(&FragmentController::getReceivedResults, boost::ref(controller))))
100 ));
101}
102
103void controller_SystemCommandJob::addSpecificOption(
104 boost::program_options::options_description_easy_init option)
105{
106 option
107 ("jobcommand", boost::program_options::value< std::string >(), "command argument for executable for 'createjobs'")
108 ("executable", boost::program_options::value< std::string >(), "executable for commands 'createjobs'")
109 ;
110}
111
112int controller_SystemCommandJob::addOtherParsings(
113 ControllerOptions &ControllerInfo,
114 boost::program_options::variables_map &vm)
115{
116 ControllerOptions_SystemCommandJob &CI =
117 reinterpret_cast<ControllerOptions_SystemCommandJob &>(ControllerInfo);
118 int status = 0;
119 status = CI.parseExecutable(vm);
120 if (status) return status;
121 status = CI.parseJobCommand(vm);
122 return status;
123}
Note: See TracBrowser for help on using the repository browser.