#include <msp/gltk/button.h>
+#include <msp/strings/format.h>
+#include "libr2c2/clock.h"
#include "libr2c2/driver.h"
#include "engineer.h"
#include "mainwindow.h"
ind_off = dynamic_cast<GLtk::Indicator *>(get_item(widgets, "ind_off"));
ind_halt = dynamic_cast<GLtk::Indicator *>(get_item(widgets, "ind_halt"));
lbl_status = dynamic_cast<GLtk::Label *>(get_item(widgets, "lbl_status"));
+ lbl_clock = dynamic_cast<GLtk::Label *>(get_item(widgets, "lbl_clock"));
dynamic_cast<GLtk::Button *>(get_item(widgets, "btn_on"))->signal_clicked.connect(sigc::mem_fun(this, &MainWindow::on_clicked));
dynamic_cast<GLtk::Button *>(get_item(widgets, "btn_off"))->signal_clicked.connect(sigc::mem_fun(this, &MainWindow::off_clicked));
driver.signal_power.connect(sigc::mem_fun(this, &MainWindow::power_event));
driver.signal_halt.connect(sigc::mem_fun(this, &MainWindow::halt_event));
+
+ engineer.get_layout().get_clock().signal_minute.connect(sigc::mem_fun(this, &MainWindow::clock_minute));
}
void MainWindow::set_status_text(const string &txt)
{
ind_halt->set_active(h);
}
+
+void MainWindow::clock_minute()
+{
+ const Time::TimeDelta &time = engineer.get_layout().get_clock().get_current_time();
+ unsigned minute = time/Time::min;
+ unsigned hour = minute/60;
+ minute %= 60;
+ lbl_clock->set_text(format("%02d:%02d", hour, minute));
+}
void Clock::tick(const Time::TimeDelta &dt)
{
+ unsigned prev_minute = current_time/Time::min;
current_time += dt*rate;
+ if(current_time>=Time::day)
+ current_time -= Time::day;
+ unsigned minute = current_time/Time::min;
+ if(minute!=prev_minute)
+ signal_minute.emit();
}
} // namespace R2C2
Catalogue &get_catalogue() const { return catalogue; }
bool has_driver() const { return driver; }
Driver &get_driver() const;
- const Clock &get_clock() const { return clock; }
+ Clock &get_clock() { return clock; }
const std::string &get_base() const { return base; }
void add(Object &);