X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/0aacdcf95cf6d4f33a2201160d472ab84148d52b..49850f467dae860e12c7851a2f8a79132f87721e:/Model/src/main.cpp?ds=sidebyside diff --git a/Model/src/main.cpp b/Model/src/main.cpp index 5f9187e..e6e52b5 100644 --- a/Model/src/main.cpp +++ b/Model/src/main.cpp @@ -8,88 +8,25 @@ #include "drainage.h" #include "exclusa.h" #include +#include +#include "simulator.h" using namespace std; using namespace PlaQui::Model; int main(int argc, char *argv[]) { - Pump *bomba1; - Exclusa *exclusa1; - Conduct *salida1; - Conduct *salida2; - Conduct *entrada; - Splitter *split; - Drainage *dren1, *dren2; - + Simulator *sim = new Simulator(argv[1]); - bomba1 = new Pump("bomba"); - bomba1->set_max_flow(30); - salida1 = new Conduct("salida_1"); - salida1->set_max_flow(2); - salida2 = new Conduct("salida_2"); - salida2->set_max_flow(5); - exclusa1 = new Exclusa("exclusa1"); + int i=0; + while (i<2) { + sim->simulate(); - split = new Splitter("splitter"); - split->set_max_flow(8); - entrada = new Conduct("entrada"); - entrada->set_max_flow(10); - - dren1 = new Drainage("drenaje1"); - dren2 = new Drainage("drenaje2"); - - bomba1->connect(exclusa1, IConector::OUT); - exclusa1->connect(bomba1, IConector::IN); - exclusa1->connect(entrada, IConector::OUT); - entrada->connect(exclusa1, IConector::IN); - entrada->connect(split, IConector::OUT); - split->connect(entrada, IConector::IN); - split->connect(salida1, IConector::OUT); - split->connect(salida2, IConector::OUT); - salida1->connect(split, IConector::IN); - salida2->connect(split, IConector::IN); - salida1->connect(dren1, IConector::OUT); - salida2->connect(dren2, IConector::OUT); - - //// LOGICA DE CONTROL!! - // CONECTO LA SALIDA DE LA EXCLUSA A LA ENTRADA DE LA BOMBA - bomba1->connect_input_logic( exclusa1->get_logic_output() ); - - int i = 0; - while (i<10) { - bomba1->update(); - exclusa1->update(); - salida1->update(); - salida2->update(); - entrada->update(); - split->update(); - dren1->update(); - dren2->update(); - - bomba1->simulate(); - exclusa1->simulate(); - salida1->simulate(); - salida2->simulate(); - entrada->simulate(); - split->simulate(); - dren1->simulate(); - dren2->simulate(); - - sleep(1); - if (i == 5) { - //bomba1->deactivate(); - // Ahora cierro la exclusa!, la bomba deberia apagarse!!! - exclusa1->close(); - } + std::cout << sim->get_state_as_xml() << std::endl << std::endl; i++; } - delete bomba1; - delete salida1; - delete salida2; - delete entrada; - delete split; + delete sim; return 1; }