namespace Model {
/** Modela objetos que recibe liquido */
-class Drain:public Control {
+class Drain:virtual public Control {
public:
/// Constructor
Drain(const std::string &_name);
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; }
};
--- /dev/null
+
+#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_
*/
bool active;
private:
- Pump(const Pump &):Source("null") {}
+ Pump(const Pump &):Source("null"),Control("null") {}
Pump &operator = (const Pump &) { return *this; }
};
namespace Model {
/** Modela objetos desde donde fluye liquido */
-class Source:public Control {
+class Source:virtual public Control {
public:
/// Constructor
Source(const std::string &_name);
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;
--- /dev/null
+
+#include "exclusa.h"
+#include <iostream>
+
+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);
+ }
+}
+
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;