X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/70d2e24643727ab1ea48e1793d609d27b7d21fed..a9318661e45dfb9853c6aba811670571a5ec3ea2:/Model/src/main.cpp?ds=inline diff --git a/Model/src/main.cpp b/Model/src/main.cpp index 3fa359e..ab4f7f6 100644 --- a/Model/src/main.cpp +++ b/Model/src/main.cpp @@ -6,77 +6,41 @@ #include "union.h" #include "splitter.h" #include "drainage.h" +#include "exclusa.h" #include +#include +#include "simulador.h" using namespace std; using namespace PlaQui::Model; int main(int argc, char *argv[]) { - Pump *bomba1; - Conduct *salida1; - Conduct *salida2; - Conduct *entrada; - Splitter *split; - Drainage *dren1, *dren2; - + Simulador *sim = new Simulador(); - 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); + sim->add_pump("bomba1"); + sim->add_conduct("c"); + sim->add_conduct("c1"); + sim->add_drainage("d"); + sim->add_tank("tanque"); - split = new Splitter("splitter"); - split->set_max_flow(8); - entrada = new Conduct("entrada"); - entrada->set_max_flow(10); + sim->connect("bomba1", "c", IConector::OUT); + sim->connect("c", "tanque", IConector::OUT); + sim->connect("tanque", "c1", IConector::OUT); + sim->connect("c1", "d", IConector::OUT); - dren1 = new Drainage("drenaje1"); - dren2 = new Drainage("drenaje2"); - - bomba1->connect(entrada, IConector::OUT); - entrada->connect(bomba1, 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); - - int i = 0; + int i=0; while (i<10) { - bomba1->update(); - salida1->update(); - salida2->update(); - entrada->update(); - split->update(); - dren1->update(); - dren2->update(); - - bomba1->simulate(); - salida1->simulate(); - salida2->simulate(); - entrada->simulate(); - split->simulate(); - dren1->simulate(); - dren2->simulate(); - - sleep(1); - if (i == 5) { - bomba1->deactivate(); + sim->simulate(); + if (i == 4) { + if (!sim->pump_deactivate("bomba1")) { + std::cout << "c no es pump :-)" << std::endl; + } } i++; } - delete bomba1; - delete salida1; - delete salida2; - delete entrada; - delete split; + delete sim; return 1; }