Changeset 209ac10 in observatorio for simulacion/SimEscenariosEconomicos
- Timestamp:
- Jul 15, 2014, 10:55:27 AM (10 years ago)
- Branches:
- simulacion
- Children:
- 4ce7106
- Parents:
- 560bc4d
- Location:
- simulacion/SimEscenariosEconomicos
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
simulacion/SimEscenariosEconomicos/graph_builder.C
r560bc4d r209ac10 193 193 } 194 194 195 DBProperties::getInstance().readFile(Fields::dbFileName);196 197 195 IOManager ioManager; 198 196 … … 200 198 201 199 try { 200 201 DBProperties::getInstance().readFile(Fields::dbFileName); 202 202 203 203 ioManager.buildGraph(Fields::xmlInputFileName, graph); -
simulacion/SimEscenariosEconomicos/svg_builder.C
r560bc4d r209ac10 17 17 # include <tpl_dynDlist.H> 18 18 19 # include <dbProperties.H> 19 20 # include <ioManager.H> 20 21 # include <process.H> … … 168 169 169 170 170 171 171 if (argp_parse (&argp_s, argc, argv, 0/*ARGP_LONG_ONLY*/,0, &arguments) != 0) 172 172 return 0; … … 174 174 int lvsUp = arguments.levelsup; 175 175 int lvsDown = arguments.levelsdown; 176 177 DBProperties & dbProp = DBProperties::getInstance(); 178 179 dbProp.setHost(arguments.host); 180 dbProp.setPort(arguments.port); 181 dbProp.setDbname(arguments.dbname); 182 dbProp.setUser(arguments.username); 183 dbProp.setPassword(arguments.password); 176 184 177 185 if (arguments.verbose) { 178 std::cout << "Creando temp.db...\n";179 }180 181 std::ofstream file("temp.db");182 183 file << arguments.host << "\n";184 file << arguments.port << "\n";185 file << arguments.dbname << "\n";186 file << arguments.username << "\n";187 file << arguments.password;188 189 if (arguments.verbose) {190 std::cout << "temp.db Creado.\n";191 }192 193 file.close();194 195 if (arguments.verbose) {196 186 std::cout << "Llenando lista de argumentos...\n"; 197 187 } … … 200 190 201 191 for (size_t i = 0; i < arguments.num_values - 1; ++i) { 202 203 192 ids.append(std::atol(arguments.values[i])); 204 205 193 } 206 194 … … 215 203 std::string gvOutputFileName = baseName + ".gv"; 216 204 217 std::string arg2 = "-s"; 218 arg2.append(svgOutputFileName); 219 220 std::string arg3 = "-g"; 221 arg3.append(gvOutputFileName); 205 const char * const xmlRoots = "temp.xml"; 222 206 223 207 IOManager ioManager; 224 208 225 209 if (arguments.verbose) { 226 std::cout << "Creando temp.xml...\n";227 } 228 229 ioManager.createXmlRootsFile(arguments.year, ids, lvsUp, lvsDown, "temp.xml");210 std::cout << "Creando " << xmlRoots << "...\n"; 211 } 212 213 ioManager.createXmlRootsFile(arguments.year, ids, lvsUp, lvsDown, xmlRoots); 230 214 231 215 if (arguments.verbose) { 232 std::cout << "temp.xml creado.\n"; 233 } 234 235 char * path = "ecosim_graph_builder"; 236 237 size_t numArgs = 5; 238 239 char * args[] = { "ecosim_graph_builder", "-itemp.xml", "-btemp.db", 240 (char *) arg2.c_str(), (char *) arg3.c_str(), 0, 0 }; 241 242 if (arguments.verbose) { 243 args[5] = "-v"; 244 ++numArgs; 245 } 246 247 if (arguments.verbose) { 248 std::cout << "Ejecutando " << path; 249 250 for (size_t i = 1; i < numArgs; ++i) { 251 std::cout << " " << args[i]; 252 } 253 254 std::cout << "\n"; 255 } 256 257 int retVal = Process::exec(path, args); 258 259 if (retVal != 0) { 260 std::cout << "Error ejecutando\n"; 261 } else if (arguments.verbose) { 262 std::cout << "Listo.\n"; 263 } 264 265 remove("temp.db"); 266 267 remove("temp.xml"); 268 269 return retVal; 216 std::cout << xmlRoots << " creado.\n"; 217 } 218 219 try { 220 221 Graph graph; 222 223 if (arguments.verbose) { 224 std::cout << "Construyendo red...\n"; 225 } 226 227 ioManager.buildGraph(xmlRoots, graph); 228 229 if (arguments.verbose) { 230 std::cout << "Red construída\n"; 231 } 232 233 if (arguments.verbose) { 234 std::cout << "Eliminando " << xmlRoots << "...\n"; 235 } 236 237 remove(xmlRoots); 238 239 if (arguments.verbose) { 240 std::cout << xmlRoots << " eliminado.\n"; 241 } 242 243 std::string dotFileName = "temp.dot"; 244 245 if (arguments.verbose) { 246 std::cout << "Generando " << dotFileName << "...\n"; 247 } 248 249 ioManager.generateDot<IOManager::NodeLabel, IOManager::ArcLabel> 250 (graph, dotFileName); 251 252 if (arguments.verbose) { 253 std::cerr << dotFileName << " generado.\n"; 254 } 255 256 int returnValue = 0; 257 258 char const * path = "dot"; 259 260 char * args[] = {"dot", "", (char *) dotFileName.c_str(), "-o", "", 0}; 261 262 args[1] = "-Tsvg"; 263 args[4] = (char *) svgOutputFileName.c_str(); 264 265 if (arguments.verbose) { 266 std::cout << "Generando " << svgOutputFileName << "...\n"; 267 } 268 269 returnValue = Process::exec(path, args); 270 271 if (returnValue == 0) { 272 if (arguments.verbose) { 273 std::cerr << svgOutputFileName << " generado.\n"; 274 } 275 } else { 276 std::cout << "Error generando " << svgOutputFileName << "\n"; 277 } 278 279 args[1] = "-Tgv"; 280 args[4] = (char *) gvOutputFileName.c_str(); 281 282 if (arguments.verbose) { 283 std::cout << "Generando " << gvOutputFileName << "...\n"; 284 } 285 286 returnValue = Process::exec(path, args); 287 288 if (returnValue == 0) { 289 if (arguments.verbose) { 290 std::cerr << gvOutputFileName << " generado.\n"; 291 } 292 } else { 293 std::cout << "Error generando " << gvOutputFileName << "\n"; 294 } 295 296 297 if (arguments.verbose) { 298 std::cout << "Eliminando " << dotFileName << "...\n"; 299 } 300 301 remove(dotFileName.c_str()); 302 303 if (arguments.verbose) { 304 std::cerr << dotFileName << " eliminado.\n"; 305 } 306 307 } catch (const std::exception & e) { 308 std::cout << "Excepción capturada: " << e.what() << std::endl; 309 return 1; 310 } 311 312 return 0; 270 313 } 271 314
Note: See TracChangeset
for help on using the changeset viewer.