* El cliente ahra tiene un boton On/Off que apaga o enciende un elemento
dependiendo de su estado actual. Anda para cualquier objeto, despues
voy a filtrar para que solo se pueda usar en exclusa y bomba.
Es muy lindo apagar la bomba de arriba a la derecha y ver como se vacia
el tanque, y cuando se vuelve a encender se llena :-)
inline Glib::ustring get_name() { return name; }
void set_position(int _x, int _y);
void set_name(Glib::ustring _name);
inline Glib::ustring get_name() { return name; }
void set_position(int _x, int _y);
void set_name(Glib::ustring _name);
+ inline bool get_open() { return open; }
inline void set_actual_flow(float f) { actual_flow = f; }
inline void set_open(bool b) { open = b; }
inline void set_extra(float f) { extra = f; }
inline void set_actual_flow(float f) { actual_flow = f; }
inline void set_open(bool b) { open = b; }
inline void set_extra(float f) { extra = f; }
public:
ViewPump(Glib::ustring _name, int orientacion);
virtual ~ViewPump();
public:
ViewPump(Glib::ustring _name, int orientacion);
virtual ~ViewPump();
+ virtual std::string get_cap_extra() { return "Estado"; }
+ virtual std::string get_extra() { return (open)?"Encendida":"Apagada"; }
Gtk::Fixed *work_place;
Gtk::Label *lbl_nombre, *lbl_color, *lbl_flujo, *lbl_extra, *lbl_cap_flujo, *lbl_cap_extra;
Gtk::Image *ico_conected;
Gtk::Fixed *work_place;
Gtk::Label *lbl_nombre, *lbl_color, *lbl_flujo, *lbl_extra, *lbl_cap_flujo, *lbl_cap_extra;
Gtk::Image *ico_conected;
+ Gtk::Button *btn_activar;
Gtk::DrawingArea *color_preview;
// Actualiza las propiedades en la ventana del item actual
Gtk::DrawingArea *color_preview;
// Actualiza las propiedades en la ventana del item actual
virtual void on_mnu_help_about();
virtual void on_dlg_connect_ok();
virtual void on_get_clicked();
virtual void on_mnu_help_about();
virtual void on_dlg_connect_ok();
virtual void on_get_clicked();
+ virtual void on_btn_activar_clicked();
virtual bool on_item_clicked(GdkEventButton *, ViewItem *);
virtual bool on_item_clicked(GdkEventButton *, ViewItem *);
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
- <widget class="GtkLabel" id="lbl_cap_color">
+ <widget class="GtkLabel" id="lbl_flujo">
<property name="visible">True</property>
<property name="visible">True</property>
- <property name="label" translatable="yes">Color : </property>
+ <property name="label" translatable="yes">...</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="ypad">0</property>
</widget>
<packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">fill</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="lbl_cap_extra">
+ <widget class="GtkLabel" id="lbl_nombre">
<property name="visible">True</property>
<property name="visible">True</property>
- <property name="label" translatable="yes">Extra : </property>
+ <property name="label" translatable="yes">...</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="ypad">0</property>
</widget>
<packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">fill</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="lbl_flujo">
+ <widget class="GtkLabel" id="lbl_cap_color">
<property name="visible">True</property>
<property name="visible">True</property>
- <property name="label" translatable="yes">...</property>
+ <property name="label" translatable="yes">Color : </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="ypad">0</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="lbl_nombre">
+ <widget class="GtkLabel" id="lbl_cap_extra">
<property name="visible">True</property>
<property name="visible">True</property>
- <property name="label" translatable="yes">...</property>
+ <property name="label" translatable="yes">Extra : </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="ypad">0</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<property name="y_options"></property>
</packing>
</child>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<property name="y_options"></property>
</packing>
</child>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options">fill</property>
</packing>
</child>
<property name="y_options">fill</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkButton" id="btn_activar">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">On/Off</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
work_place = 0;
lbl_cap_flujo = lbl_cap_extra = lbl_extra = lbl_nombre = lbl_color = lbl_flujo = 0;
work_place = 0;
lbl_cap_flujo = lbl_cap_extra = lbl_extra = lbl_nombre = lbl_color = lbl_flujo = 0;
+ rg->get_widget("btn_activar", btn_activar);
rg->get_widget("color_preview", color_preview);
rg->get_widget("lbl_nombre", lbl_nombre);
rg->get_widget("lbl_extra", lbl_extra);
rg->get_widget("color_preview", color_preview);
rg->get_widget("lbl_nombre", lbl_nombre);
rg->get_widget("lbl_extra", lbl_extra);
exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit));
about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about));
btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) );
exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit));
about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about));
btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) );
+ btn_activar->signal_clicked().connect( SigC::slot(*this, &Principal::on_btn_activar_clicked) );
conexion = NULL;
is_xml_loaded = false;
conexion = NULL;
is_xml_loaded = false;
+void Principal::on_btn_activar_clicked()
+{
+ if ((conexion == NULL) || (last_selected == NULL)) return;
+
+ PlaQui::Server::Command c("plant", "set");
+ c.add_arg("default");
+ c.add_arg(last_selected->get_name());
+ c.add_arg("open");
+
+ if (last_selected->get_open())
+ c.add_arg("false");
+ else
+ c.add_arg("true");
+
+ conexion->send(c);
+}
+
void Principal::on_mnu_file_disconnect()
{
if (conexion == NULL) return;
void Principal::on_mnu_file_disconnect()
{
if (conexion == NULL) return;
color_preview->modify_bg(Gtk::STATE_NORMAL, last_selected->get_color());
color_preview->queue_draw();
color_preview->modify_bg(Gtk::STATE_NORMAL, last_selected->get_color());
color_preview->queue_draw();
-
- std::cout << last_selected->get_name() << " " << last_selected->get_color().get_red() << std::endl;
}
void Principal::on_conexion_connected()
}
void Principal::on_conexion_connected()
void Tank::simulate()
{
if (!updated) return;
void Tank::simulate()
{
if (!updated) return;
+ RGB in_color;
+
+ std::list<IConector *>::iterator i = in_list.begin();
+ if (i != in_list.end()) {
+ PlantItem *o = (PlantItem *)(*i);
+ in_color = o->get_color();
+ }
// le resto lo que entrego
litros -= actual_out_flow;
// le resto lo que entrego
litros -= actual_out_flow;
+
+ // calculo el nuevo color
+ int r, g, b;
+ float l = litros+actual_in_flow;
+
+ r = (int)(fluid_color.r()*litros/l + in_color.r()*actual_in_flow/l);
+ g = (int)(fluid_color.g()*litros/l + in_color.g()*actual_in_flow/l);
+ b = (int)(fluid_color.b()*litros/l + in_color.b()*actual_in_flow/l);
+
+ fluid_color = RGB(r,g,b);
+
- litros += actual_in_flow;
std::cout << name << "Capacidad: " << capacity;
std::cout << " Litros : " << litros << std::endl;
std::cout << name << "Capacidad: " << capacity;
std::cout << " Litros : " << litros << std::endl;
void Tank::get_state_as_xml(std::stringstream &out)
{
void Tank::get_state_as_xml(std::stringstream &out)
{
- // El tanque no emite flujo actual!
+ PlantItem::get_state_as_xml(out);
+
out << "\t<tank name=\"" << name << "\">" << std::endl;
out << "\t\t<capacity>" << capacity << "</capacity>" << std::endl;
out << "\t\t<litros>" << litros << "</litros>" << std::endl;
out << "\t<tank name=\"" << name << "\">" << std::endl;
out << "\t\t<capacity>" << capacity << "</capacity>" << std::endl;
out << "\t\t<litros>" << litros << "</litros>" << std::endl;