From: Ricardo Markiewicz Date: Thu, 6 Nov 2003 03:19:49 +0000 (+0000) Subject: * Se agrega la exclusa (alguien lo traduce ?, solo se me ocurre CutKey) X-Git-Tag: svn_import~344 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/f031c89fa8a00ea12ff7290569ec507f44402458?ds=inline * Se agrega la exclusa (alguien lo traduce ?, solo se me ocurre CutKey) * Se agrega herencia virtual de Drain y Source sobre Control, para poder poner el tanque. Se ajustan Pump y Drainage para que anden con el nuevo modelo de herencia. --- diff --git a/Model/include/drain.h b/Model/include/drain.h index a24c9a3..25f75d8 100644 --- a/Model/include/drain.h +++ b/Model/include/drain.h @@ -9,7 +9,7 @@ namespace PlaQui { namespace Model { /** Modela objetos que recibe liquido */ -class Drain:public Control { +class Drain:virtual public Control { public: /// Constructor Drain(const std::string &_name); diff --git a/Model/include/drainage.h b/Model/include/drainage.h index 0491fff..2ec4d2b 100644 --- a/Model/include/drainage.h +++ b/Model/include/drainage.h @@ -26,7 +26,7 @@ public: virtual void set_capacity(float _f) { /* IGNORO EL CAMBIO DE CAPACIDAD! */ } protected: private: - Drainage(const Drainage &):Drain("null") {} + Drainage(const Drainage &):Drain("null"),Control("null") {} Drainage &operator = (const Drainage &) { return *this; } }; diff --git a/Model/include/exclusa.h b/Model/include/exclusa.h new file mode 100644 index 0000000..db24be4 --- /dev/null +++ b/Model/include/exclusa.h @@ -0,0 +1,33 @@ + +#ifndef _EXCLUSE_H_ +#define _EXCLUSE_H_ + +#include "control.h" + +namespace PlaQui { + +namespace Model { + +class Exclusa:public Control { +public: + /// Constructor + Exclusa(const std::string &_name); + /// Destructor + virtual ~Exclusa(); + + virtual void update(int dir=OUT); + virtual void simulate(); + virtual void recieve_msg(int msg, IConector *who, void *data); + + virtual bool get_output() { return open; } +protected: + bool open; +private: + Exclusa():Control("null") {} + Exclusa &operator = (const Exclusa &) { return *this; } +}; + +} +} + +#endif // _EXCLUSE_H_ diff --git a/Model/include/pump.h b/Model/include/pump.h index ab7966f..6d13762 100644 --- a/Model/include/pump.h +++ b/Model/include/pump.h @@ -51,7 +51,7 @@ protected: */ bool active; private: - Pump(const Pump &):Source("null") {} + Pump(const Pump &):Source("null"),Control("null") {} Pump &operator = (const Pump &) { return *this; } }; diff --git a/Model/include/source.h b/Model/include/source.h index fde6511..8874dac 100644 --- a/Model/include/source.h +++ b/Model/include/source.h @@ -9,7 +9,7 @@ namespace PlaQui { namespace Model { /** Modela objetos desde donde fluye liquido */ -class Source:public Control { +class Source:virtual public Control { public: /// Constructor Source(const std::string &_name); diff --git a/Model/src/drainage.cpp b/Model/src/drainage.cpp index 95c55e8..ac2868a 100644 --- a/Model/src/drainage.cpp +++ b/Model/src/drainage.cpp @@ -4,7 +4,7 @@ using namespace PlaQui::Model; -Drainage::Drainage(const std::string &_name):Drain(_name) +Drainage::Drainage(const std::string &_name):Drain(_name),Control(_name) { in_slots = 1; out_slots = 0; diff --git a/Model/src/exclusa.cpp b/Model/src/exclusa.cpp new file mode 100644 index 0000000..553c8ce --- /dev/null +++ b/Model/src/exclusa.cpp @@ -0,0 +1,42 @@ + +#include "exclusa.h" +#include + +using namespace PlaQui::Model; + +Exclusa::Exclusa(const std::string &_name):Control(_name) +{ + open = true; + in_slots = out_slots = 1; +} + +Exclusa::~Exclusa() +{ +} + +void Exclusa::update(int dir) +{ + // no hace nada +} + +void Exclusa::simulate() +{ + std::cout << name << ": " << ((open)?"Abierta":"Cerrada") << std::endl; +} + +void Exclusa::recieve_msg(int msg, IConector *who, void *data) +{ + float temp; + switch (msg) { + case MSG_QUERY_MAX_FLOW_OUT: + temp = *((float *)data); + send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &temp); + break; + case MSG_RESPONSE_MAX_FLOW: + temp = *((float *)data); + break; + default: + Control::recieve_msg(msg, who, data); + } +} + diff --git a/Model/src/pump.cpp b/Model/src/pump.cpp index 086138f..78d4dcd 100644 --- a/Model/src/pump.cpp +++ b/Model/src/pump.cpp @@ -4,7 +4,7 @@ using namespace PlaQui::Model; -Pump::Pump(const std::string &_name):Source(_name) +Pump::Pump(const std::string &_name):Source(_name),Control(_name) { in_slots = 0; out_slots = 1;