5 using namespace PlaQui::Model;
7 Tank::Tank(const std::string &_name):Source(_name),Drain(_name),Control(_name)
16 bool Tank::get_output()
21 void Tank::update(int dir)
30 // le resto lo que entrego
31 litros -= actual_out_flow;
32 // le sumo lo que recibo
33 litros += actual_in_flow;
35 std::cout << name << "Capacidad: " << capacity;
36 std::cout << " Litros : " << litros << std::endl;
40 void Tank::recieve_msg(int msg, IConector *who, void *data)
44 // Verifico si esta conectado a mi entrada
45 std::list<IConector *>::iterator i;
46 for(i=in_list.begin(); i!=in_list.end(); i++) {
47 if ((*i) == who) pos = IN;
51 case MSG_QUERY_MAX_FLOW_OUT:
52 actual_in_flow = capacity - litros;
53 if (*((float *)data) < actual_in_flow)
54 actual_in_flow = *((float *)data);
55 actual_out_flow = litros;
56 send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_out_flow);
58 who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &actual_in_flow);
61 case MSG_RESPONSE_MAX_FLOW:
63 if (*((float *)data) < actual_out_flow)
64 actual_out_flow = *((float *)data);
69 void Tank::get_state_as_xml(std::stringstream &out)
71 // El tanque no emite flujo actual!
72 out << "\t<tank name=\"" << name << "\">" << std::endl;
73 out << "\t\t<capacity>" << capacity << "</capacity>" << std::endl;
74 out << "\t\t<litros>" << litros << "</litros>" << std::endl;
75 out << "\t</tank>" << std::endl;