| [7ca772e] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
 | 4 |  * Copyright (C)  2011 University of Bonn. All rights reserved.
 | 
|---|
 | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | /*
 | 
|---|
 | 9 |  * \file controller.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  * This file strongly follows the Serialization example from the boost::asio
 | 
|---|
 | 12 |  * library (see client.cpp)
 | 
|---|
 | 13 |  *
 | 
|---|
 | 14 |  *  Created on: Nov 27, 2011
 | 
|---|
 | 15 |  *      Author: heber
 | 
|---|
 | 16 |  */
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | 
 | 
|---|
 | 19 | // include config.h
 | 
|---|
 | 20 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 21 | #include <config.h>
 | 
|---|
 | 22 | #endif
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | // boost asio needs specific operator new
 | 
|---|
 | 25 | #include <boost/asio.hpp>
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
 | 28 | 
 | 
|---|
| [986885] | 29 | #include <boost/archive/text_oarchive.hpp>
 | 
|---|
 | 30 | #include <boost/archive/text_iarchive.hpp>
 | 
|---|
| [ff60cfa] | 31 | #include <fstream>
 | 
|---|
| [7ca772e] | 32 | #include <iostream>
 | 
|---|
 | 33 | #include <map>
 | 
|---|
| [ff60cfa] | 34 | #include <sstream>
 | 
|---|
 | 35 | #include <streambuf>
 | 
|---|
 | 36 | #include <vector>
 | 
|---|
| [7ca772e] | 37 | 
 | 
|---|
 | 38 | #include "atexit.hpp"
 | 
|---|
 | 39 | #include "CodePatterns/Info.hpp"
 | 
|---|
 | 40 | #include "CodePatterns/Log.hpp"
 | 
|---|
| [d7bb9b1] | 41 | #include "Fragmentation/EnergyMatrix.hpp"
 | 
|---|
 | 42 | #include "Fragmentation/ForceMatrix.hpp"
 | 
|---|
 | 43 | #include "Fragmentation/KeySetsContainer.hpp"
 | 
|---|
| [d4885d] | 44 | #include "FragmentController.hpp"
 | 
|---|
| [ff60cfa] | 45 | #include "Jobs/MPQCCommandJob.hpp"
 | 
|---|
| [d7bb9b1] | 46 | #include "Jobs/MPQCCommandJob_MPQCData.hpp"
 | 
|---|
| [d920b9] | 47 | #include "Jobs/SystemCommandJob.hpp"
 | 
|---|
| [7670865] | 48 | #include "Results/FragmentResult.hpp"
 | 
|---|
| [7ca772e] | 49 | 
 | 
|---|
 | 50 | enum CommandIndices {
 | 
|---|
 | 51 |   UnknownCommandIndex = 0,
 | 
|---|
| [ff60cfa] | 52 |   AddJobsIndex = 1,
 | 
|---|
 | 53 |   CreateJobsIndex = 2,
 | 
|---|
 | 54 |   CheckResultsIndex = 3,
 | 
|---|
 | 55 |   ReceiveResultsIndex = 4,
 | 
|---|
| [986885] | 56 |   ReceiveMPQCIndex = 5,
 | 
|---|
 | 57 |   ShutdownIndex = 6,
 | 
|---|
| [7ca772e] | 58 | };
 | 
|---|
 | 59 | 
 | 
|---|
| [ff60cfa] | 60 | 
 | 
|---|
| [4dd16e] | 61 | /** Creates a SystemCommandJob out of give \a command with \a argument.
 | 
|---|
| [d1dbfc] | 62 |  *
 | 
|---|
| [4dd16e] | 63 |  * @param jobs created job is added to this vector
 | 
|---|
 | 64 |  * @param command command to execute for SystemCommandJob
 | 
|---|
 | 65 |  * @param argument argument for command to execute
 | 
|---|
 | 66 |  * @param nextid id for this job
 | 
|---|
| [d1dbfc] | 67 |  */
 | 
|---|
| [554809] | 68 | void createjobs(
 | 
|---|
 | 69 |     std::vector<FragmentJob::ptr> &jobs,
 | 
|---|
 | 70 |     const std::string &command,
 | 
|---|
 | 71 |     const std::string &argument,
 | 
|---|
 | 72 |     const JobId_t nextid)
 | 
|---|
| [d1dbfc] | 73 | {
 | 
|---|
| [4dd16e] | 74 | 
 | 
|---|
| [554809] | 75 |   FragmentJob::ptr testJob( new SystemCommandJob(command, argument, nextid) );
 | 
|---|
| [7ca772e] | 76 |   jobs.push_back(testJob);
 | 
|---|
| [554809] | 77 |   LOG(1, "INFO: Added one SystemCommandJob.");
 | 
|---|
| [7ca772e] | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
| [d1dbfc] | 80 | /** Creates a MPQCCommandJob with argument \a filename.
 | 
|---|
 | 81 |  *
 | 
|---|
 | 82 |  * @param jobs created job is added to this vector
 | 
|---|
 | 83 |  * @param filename filename being argument to job
 | 
|---|
 | 84 |  * @param nextid id for this job
 | 
|---|
 | 85 |  */
 | 
|---|
 | 86 | void parsejob(
 | 
|---|
 | 87 |     std::vector<FragmentJob::ptr> &jobs,
 | 
|---|
 | 88 |     const std::string &filename,
 | 
|---|
 | 89 |     const JobId_t nextid)
 | 
|---|
| [ff60cfa] | 90 | {
 | 
|---|
 | 91 |   std::ifstream file;
 | 
|---|
 | 92 |   file.open(filename.c_str());
 | 
|---|
 | 93 |   ASSERT( file.good(), "parsejob() - file "+filename+" does not exist.");
 | 
|---|
 | 94 |   std::string output((std::istreambuf_iterator<char>(file)),
 | 
|---|
 | 95 |       std::istreambuf_iterator<char>());
 | 
|---|
| [d1dbfc] | 96 |   FragmentJob::ptr testJob( new MPQCCommandJob(output, nextid) );
 | 
|---|
| [ff60cfa] | 97 |   jobs.push_back(testJob);
 | 
|---|
 | 98 |   file.close();
 | 
|---|
 | 99 |   LOG(1, "INFO: Added MPQCCommandJob from file "+filename+".");
 | 
|---|
 | 100 | }
 | 
|---|
 | 101 | 
 | 
|---|
| [d1dbfc] | 102 | /** Print received results.
 | 
|---|
 | 103 |  *
 | 
|---|
| [4dd16e] | 104 |  * @param results received results to print
 | 
|---|
| [d1dbfc] | 105 |  */
 | 
|---|
| [4dd16e] | 106 | void printReceivedResults(std::vector<FragmentResult::ptr> &results)
 | 
|---|
| [7ca772e] | 107 | {
 | 
|---|
| [35f587] | 108 |   for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
 | 
|---|
| [7ca772e] | 109 |       iter != results.end(); ++iter)
 | 
|---|
| [35f587] | 110 |     LOG(1, "RESULT: job #"+toString((*iter)->getId())+": "+toString((*iter)->result));
 | 
|---|
| [7ca772e] | 111 | }
 | 
|---|
 | 112 | 
 | 
|---|
| [d7bb9b1] | 113 | /** Print MPQCData from received results.
 | 
|---|
| [986885] | 114 |  *
 | 
|---|
| [4dd16e] | 115 |  * @param results vector of all received FragmentResult's
 | 
|---|
 | 116 |  * @param KeySetFilename filename containing keysets
 | 
|---|
| [986885] | 117 |  */
 | 
|---|
| [d7bb9b1] | 118 | bool printReceivedMPQCResults(
 | 
|---|
 | 119 |     std::vector<FragmentResult::ptr> &results,
 | 
|---|
 | 120 |     const std::string &KeySetFilename)
 | 
|---|
| [986885] | 121 | {
 | 
|---|
| [d7bb9b1] | 122 |   EnergyMatrix Energy;
 | 
|---|
 | 123 |   EnergyMatrix EnergyFragments;
 | 
|---|
 | 124 |   ForceMatrix Force;
 | 
|---|
 | 125 |   ForceMatrix ForceFragments;
 | 
|---|
 | 126 |   KeySetsContainer KeySet;
 | 
|---|
 | 127 | 
 | 
|---|
 | 128 |   // place results into EnergyMatrix and ForceMatrix
 | 
|---|
 | 129 |   //if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return false;
 | 
|---|
 | 130 |   //if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return false;
 | 
|---|
| [986885] | 131 |   // combine all found data
 | 
|---|
 | 132 |   std::vector<MPQCData> fragmentData(results.size());
 | 
|---|
 | 133 |   MPQCData combinedData;
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |   LOG(2, "DEBUG: Parsing now through " << results.size() << " results.");
 | 
|---|
 | 136 |   for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
 | 
|---|
 | 137 |       iter != results.end(); ++iter) {
 | 
|---|
 | 138 |     LOG(1, "RESULT: job #"+toString((*iter)->getId())+": "+toString((*iter)->result));
 | 
|---|
 | 139 |     MPQCData extractedData;
 | 
|---|
 | 140 |     std::stringstream inputstream((*iter)->result);
 | 
|---|
 | 141 |     boost::archive::text_iarchive ia(inputstream);
 | 
|---|
 | 142 |     ia >> extractedData;
 | 
|---|
 | 143 |     LOG(1, "INFO: extracted data is " << extractedData << ".");
 | 
|---|
 | 144 |   }
 | 
|---|
| [d7bb9b1] | 145 | 
 | 
|---|
 | 146 |   if (!Energy.InitialiseIndices()) return false;
 | 
|---|
 | 147 | 
 | 
|---|
 | 148 |   if (!Force.ParseIndices(KeySetFilename.c_str())) return false;
 | 
|---|
 | 149 | 
 | 
|---|
 | 150 |   if (!KeySet.ParseKeySets(KeySetFilename.c_str(), Force.RowCounter, Force.MatrixCounter)) return false;
 | 
|---|
 | 151 | 
 | 
|---|
 | 152 |   if (!KeySet.ParseManyBodyTerms()) return false;
 | 
|---|
 | 153 | 
 | 
|---|
 | 154 |   if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return false;
 | 
|---|
 | 155 |   if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return false;
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 |   if(!Energy.SetLastMatrix(0., 0)) return false;
 | 
|---|
 | 158 |   if(!Force.SetLastMatrix(0., 2)) return false;
 | 
|---|
 | 159 | 
 | 
|---|
 | 160 |   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
 | 
|---|
 | 161 |     // --------- sum up energy --------------------
 | 
|---|
 | 162 |     LOG(1, "INFO: Summing energy of order " << BondOrder+1 << " ...");
 | 
|---|
 | 163 |     if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return false;
 | 
|---|
 | 164 |     if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return false;
 | 
|---|
 | 165 | 
 | 
|---|
 | 166 |     // --------- sum up Forces --------------------
 | 
|---|
 | 167 |     LOG(1, "INFO: Summing forces of order " << BondOrder+1 << " ...");
 | 
|---|
 | 168 |     if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return false;
 | 
|---|
 | 169 |     if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return false;
 | 
|---|
 | 170 |   }
 | 
|---|
 | 171 | 
 | 
|---|
 | 172 |   return true;
 | 
|---|
| [986885] | 173 | }
 | 
|---|
 | 174 | 
 | 
|---|
| [d7bb9b1] | 175 | 
 | 
|---|
| [7ca772e] | 176 | /** Returns a unique index for every command to allow switching over it.
 | 
|---|
 | 177 |  *
 | 
|---|
 | 178 |  * \param &commandmap map with command strings
 | 
|---|
 | 179 |  * \param &cmd command string
 | 
|---|
 | 180 |  * \return index from CommandIndices: UnkownCommandIndex - unknown command, else - command index
 | 
|---|
 | 181 |  */
 | 
|---|
 | 182 | CommandIndices getCommandIndex(std::map<std::string, CommandIndices> &commandmap, const std::string &cmd)
 | 
|---|
 | 183 | {
 | 
|---|
 | 184 |   std::map<std::string, CommandIndices>::const_iterator iter = commandmap.find(cmd);
 | 
|---|
 | 185 |   if (iter != commandmap.end())
 | 
|---|
 | 186 |     return iter->second;
 | 
|---|
 | 187 |   else
 | 
|---|
 | 188 |     return UnknownCommandIndex;
 | 
|---|
 | 189 | }
 | 
|---|
 | 190 | 
 | 
|---|
 | 191 | 
 | 
|---|
 | 192 | int main(int argc, char* argv[])
 | 
|---|
 | 193 | {
 | 
|---|
 | 194 |   // from this moment on, we need to be sure to deeinitialize in the correct order
 | 
|---|
 | 195 |   // this is handled by the cleanup function
 | 
|---|
 | 196 |   atexit(cleanUp);
 | 
|---|
 | 197 | 
 | 
|---|
 | 198 |   setVerbosity(3);
 | 
|---|
 | 199 | 
 | 
|---|
 | 200 |   size_t Exitflag = 0;
 | 
|---|
| [ff60cfa] | 201 |   typedef std::map<std::string, CommandIndices> CommandsMap_t;
 | 
|---|
 | 202 |   CommandsMap_t CommandsMap;
 | 
|---|
 | 203 |   CommandsMap.insert( std::make_pair("addjobs", AddJobsIndex) );
 | 
|---|
 | 204 |   CommandsMap.insert( std::make_pair("createjobs", CreateJobsIndex) );
 | 
|---|
| [7ca772e] | 205 |   CommandsMap.insert( std::make_pair("checkresults", CheckResultsIndex) );
 | 
|---|
 | 206 |   CommandsMap.insert( std::make_pair("receiveresults", ReceiveResultsIndex) );
 | 
|---|
| [986885] | 207 |   CommandsMap.insert( std::make_pair("receivempqc", ReceiveMPQCIndex) );
 | 
|---|
| [7ca772e] | 208 |   CommandsMap.insert( std::make_pair("shutdown", ShutdownIndex) );
 | 
|---|
 | 209 |   try
 | 
|---|
 | 210 |   {
 | 
|---|
 | 211 |     // Check command line arguments.
 | 
|---|
| [ff60cfa] | 212 |     if (argc < 4)
 | 
|---|
| [7ca772e] | 213 |     {
 | 
|---|
| [ff60cfa] | 214 |       std::cerr << "Usage: " << argv[0] << " <host> <port> <command> [options to command]" << std::endl;
 | 
|---|
 | 215 |       std::cerr << "List of available commands:" << std::endl;
 | 
|---|
 | 216 |       for(CommandsMap_t::const_iterator iter = CommandsMap.begin();
 | 
|---|
 | 217 |           iter != CommandsMap.end(); ++iter) {
 | 
|---|
 | 218 |         std::cerr << "\t" << iter->first << std::endl;
 | 
|---|
 | 219 |       }
 | 
|---|
| [d7bb9b1] | 220 |       return false;
 | 
|---|
| [7ca772e] | 221 |     }
 | 
|---|
 | 222 | 
 | 
|---|
 | 223 |     boost::asio::io_service io_service;
 | 
|---|
 | 224 |     FragmentController controller(io_service);
 | 
|---|
 | 225 | 
 | 
|---|
| [d1dbfc] | 226 |     // Initial phase: information gathering from server
 | 
|---|
 | 227 | 
 | 
|---|
 | 228 |     switch(getCommandIndex(CommandsMap, argv[3])) {
 | 
|---|
 | 229 |       case AddJobsIndex:
 | 
|---|
 | 230 |       {
 | 
|---|
 | 231 |         if (argc < 5) {
 | 
|---|
 | 232 |           ELOG(1, "Please add a filename for the MPQCCommandJob.");
 | 
|---|
 | 233 |         } else {
 | 
|---|
 | 234 |           // get an id for every filename
 | 
|---|
 | 235 |           for (int argcount = 4; argcount < argc; ++argcount) {
 | 
|---|
| [4dd16e] | 236 |             controller.requestId(argv[1], argv[2]);
 | 
|---|
| [d1dbfc] | 237 |           }
 | 
|---|
 | 238 |         }
 | 
|---|
 | 239 |         break;
 | 
|---|
 | 240 |       }
 | 
|---|
 | 241 |       case CreateJobsIndex:
 | 
|---|
 | 242 |       {
 | 
|---|
| [554809] | 243 |         std::vector<FragmentJob::ptr> jobs;
 | 
|---|
 | 244 |         if (argc < 6) {
 | 
|---|
 | 245 |           ELOG(1, "'createjobs' requires two options: [command] [argument].");
 | 
|---|
 | 246 |         } else {
 | 
|---|
| [4dd16e] | 247 |           controller.requestId(argv[1], argv[2]);
 | 
|---|
| [554809] | 248 |         }
 | 
|---|
| [d1dbfc] | 249 |         break;
 | 
|---|
 | 250 |       }
 | 
|---|
 | 251 |       case CheckResultsIndex:
 | 
|---|
 | 252 |         break;
 | 
|---|
 | 253 |       case ReceiveResultsIndex:
 | 
|---|
 | 254 |         break;
 | 
|---|
| [986885] | 255 |       case ReceiveMPQCIndex:
 | 
|---|
 | 256 |         break;
 | 
|---|
| [d1dbfc] | 257 |       case ShutdownIndex:
 | 
|---|
 | 258 |         break;
 | 
|---|
 | 259 |       case UnknownCommandIndex:
 | 
|---|
 | 260 |       default:
 | 
|---|
 | 261 |         ELOG(1, "Unrecognized command '"+toString(argv[3])+"'.");
 | 
|---|
 | 262 |         break;
 | 
|---|
 | 263 |     }
 | 
|---|
 | 264 | 
 | 
|---|
 | 265 |     {
 | 
|---|
 | 266 |       io_service.reset();
 | 
|---|
 | 267 |       Info info("io_service: Phase One");
 | 
|---|
 | 268 |       io_service.run();
 | 
|---|
 | 269 |     }
 | 
|---|
 | 270 | 
 | 
|---|
 | 271 |     // Second phase: Building jobs and sending information to server
 | 
|---|
 | 272 | 
 | 
|---|
| [7ca772e] | 273 |     switch(getCommandIndex(CommandsMap, argv[3])) {
 | 
|---|
| [ff60cfa] | 274 |       case AddJobsIndex:
 | 
|---|
 | 275 |       {
 | 
|---|
 | 276 |         std::vector<FragmentJob::ptr> jobs;
 | 
|---|
| [d1dbfc] | 277 |         if (argc < 5) {
 | 
|---|
| [ff60cfa] | 278 |           ELOG(1, "Please add a filename for the MPQCCommandJob.");
 | 
|---|
 | 279 |         } else {
 | 
|---|
 | 280 |           for (int argcount = 4; argcount < argc; ++argcount) {
 | 
|---|
| [4dd16e] | 281 |             const JobId_t next_id = controller.getAvailableId();
 | 
|---|
| [d1dbfc] | 282 |             const std::string filename(argv[argcount]);
 | 
|---|
 | 283 |             LOG(1, "INFO: Creating MPQCCommandJob with filename'"
 | 
|---|
 | 284 |                 +filename+"', and id "+toString(next_id)+".");
 | 
|---|
 | 285 |             parsejob(jobs, filename, next_id);
 | 
|---|
| [ff60cfa] | 286 |           }
 | 
|---|
| [4dd16e] | 287 |           controller.addJobs(jobs);
 | 
|---|
 | 288 |           controller.sendJobs(argv[1], argv[2]);
 | 
|---|
| [ff60cfa] | 289 |         }
 | 
|---|
 | 290 |         break;
 | 
|---|
 | 291 |       }
 | 
|---|
 | 292 |       case CreateJobsIndex:
 | 
|---|
| [7ca772e] | 293 |       {
 | 
|---|
| [78ad7d] | 294 |         std::vector<FragmentJob::ptr> jobs;
 | 
|---|
| [554809] | 295 |         if (argc < 6) {
 | 
|---|
| [4dd16e] | 296 |           ELOG(1, "'createjobs' requires two options: [command] [argument].");
 | 
|---|
 | 297 |         } else {
 | 
|---|
 | 298 |           const JobId_t next_id = controller.getAvailableId();
 | 
|---|
 | 299 |           createjobs(jobs, argv[4], argv[5], next_id);
 | 
|---|
 | 300 |           controller.addJobs(jobs);
 | 
|---|
 | 301 |           controller.sendJobs(argv[1], argv[2]);
 | 
|---|
| [554809] | 302 |         }
 | 
|---|
| [7ca772e] | 303 |         break;
 | 
|---|
 | 304 |       }
 | 
|---|
 | 305 |       case CheckResultsIndex:
 | 
|---|
 | 306 |       {
 | 
|---|
| [4dd16e] | 307 |         controller.checkResults(argv[1], argv[2]);
 | 
|---|
| [7ca772e] | 308 |         break;
 | 
|---|
 | 309 |       }
 | 
|---|
 | 310 |       case ReceiveResultsIndex:
 | 
|---|
 | 311 |       {
 | 
|---|
| [4dd16e] | 312 |         controller.receiveResults(argv[1], argv[2]);
 | 
|---|
| [7ca772e] | 313 |         break;
 | 
|---|
 | 314 |       }
 | 
|---|
| [986885] | 315 |       case ReceiveMPQCIndex:
 | 
|---|
 | 316 |       {
 | 
|---|
| [4dd16e] | 317 |         controller.receiveResults(argv[1], argv[2]);
 | 
|---|
| [986885] | 318 |         break;
 | 
|---|
 | 319 |       }
 | 
|---|
| [7ca772e] | 320 |       case ShutdownIndex:
 | 
|---|
 | 321 |       {
 | 
|---|
| [4dd16e] | 322 |         controller.shutdown(argv[1], argv[2]);
 | 
|---|
| [7ca772e] | 323 |         break;
 | 
|---|
 | 324 |       }
 | 
|---|
 | 325 |       case UnknownCommandIndex:
 | 
|---|
 | 326 |       default:
 | 
|---|
 | 327 |         ELOG(0, "Unrecognized command '"+toString(argv[3])+"'.");
 | 
|---|
 | 328 |         break;
 | 
|---|
 | 329 |     }
 | 
|---|
 | 330 | 
 | 
|---|
 | 331 |     {
 | 
|---|
| [d1dbfc] | 332 |       io_service.reset();
 | 
|---|
 | 333 |       Info info("io_service: Phase Two");
 | 
|---|
| [7ca772e] | 334 |       io_service.run();
 | 
|---|
 | 335 |     }
 | 
|---|
 | 336 | 
 | 
|---|
| [d1dbfc] | 337 |     // Final phase: Print result of command
 | 
|---|
 | 338 | 
 | 
|---|
| [7ca772e] | 339 |     switch(getCommandIndex(CommandsMap, argv[3])) {
 | 
|---|
| [ff60cfa] | 340 |       case AddJobsIndex:
 | 
|---|
 | 341 |       case CreateJobsIndex:
 | 
|---|
| [7ca772e] | 342 |         break;
 | 
|---|
 | 343 |       case CheckResultsIndex:
 | 
|---|
 | 344 |       {
 | 
|---|
| [4dd16e] | 345 |         controller.printDoneJobs();
 | 
|---|
| [7ca772e] | 346 |         break;
 | 
|---|
 | 347 |       }
 | 
|---|
 | 348 |       case ReceiveResultsIndex:
 | 
|---|
 | 349 |       {
 | 
|---|
| [4dd16e] | 350 |         std::vector<FragmentResult::ptr> results = controller.getReceivedResults();
 | 
|---|
 | 351 |         printReceivedResults(results);
 | 
|---|
| [7ca772e] | 352 |         break;
 | 
|---|
 | 353 |       }
 | 
|---|
| [986885] | 354 |       case ReceiveMPQCIndex:
 | 
|---|
 | 355 |       {
 | 
|---|
 | 356 |         if (argc == 4) {
 | 
|---|
 | 357 |           ELOG(1, "'receivempqc' requires one option: [KeySetFilename].");
 | 
|---|
 | 358 |         } else {
 | 
|---|
 | 359 |           const std::string KeySetFilename = argv[4];
 | 
|---|
 | 360 |           LOG(1, "INFO: Parsing id associations from " << KeySetFilename << ".");
 | 
|---|
| [4dd16e] | 361 |           std::vector<FragmentResult::ptr> results = controller.getReceivedResults();
 | 
|---|
| [d7bb9b1] | 362 |           printReceivedMPQCResults(results, KeySetFilename);
 | 
|---|
| [986885] | 363 |         }
 | 
|---|
 | 364 |         break;
 | 
|---|
 | 365 |       }
 | 
|---|
| [7ca772e] | 366 |       case ShutdownIndex:
 | 
|---|
 | 367 |         break;
 | 
|---|
 | 368 |       case UnknownCommandIndex:
 | 
|---|
 | 369 |       default:
 | 
|---|
 | 370 |         ELOG(0, "Unrecognized command '"+toString(argv[3])+"'.");
 | 
|---|
 | 371 |         break;
 | 
|---|
 | 372 |     }
 | 
|---|
 | 373 |     Exitflag = controller.getExitflag();
 | 
|---|
 | 374 |   }
 | 
|---|
 | 375 |   catch (std::exception& e)
 | 
|---|
 | 376 |   {
 | 
|---|
 | 377 |     std::cerr << e.what() << std::endl;
 | 
|---|
 | 378 |   }
 | 
|---|
 | 379 | 
 | 
|---|
 | 380 |   return Exitflag;
 | 
|---|
 | 381 | }
 | 
|---|
| [4dd16e] | 382 | 
 | 
|---|