MTRSetup.h
00001 #ifndef _MTRSETUP_H
00002 #define _MTRSETUP_H
00003
00009
00010 #include <fstream>
00011 #include <gtkmm.h>
00012 #include <modbus/ModbusRTUMaster.h>
00013 #include <modbus/ModbusHelpers.h>
00014 #include <extensions/MTR.h>
00015
00021 class MRMReCreator
00022 {
00023 public:
00024 MRMReCreator();
00026 void check();
00027
00028 ModbusRTUMaster* getMRM()
00029 { return mb_; }
00031 bool plugged()
00032 { return plugged_; }
00034 bool MRMCreated() const
00035 { return mb_ != NULL; }
00037 void changeDev(const Glib::ustring dev);
00039 void setSpeed(const Glib::ustring speed)
00040 { speed_ = speed; }
00042 void setTimeout(int timeout)
00043 { timeout_ = timeout; }
00044
00045 private:
00046 Glib::ustring dev_;
00047 Glib::ustring speed_;
00048 int timeout_;
00049
00050 bool plugged_;
00051 ModbusRTUMaster *mb_;
00052
00053 bool checkPlugged();
00054 void reCreate();
00055 };
00061 class MTRSetup {
00062
00063 private:
00064 Gtk::Dialog *MTR_Setup, *dialog;
00065 Gtk::Frame *frame_settings, *frame_autodetect, *frame_prog;
00066 Gtk::VButtonBox *box_actions;
00067 Gtk::ComboBoxEntry *combo_dev, *combo_speed, *combo_fn;
00068 Gtk::SpinButton *spin_addr, *spin_timeout, *spin_beg, *spin_end, *spin_reg;
00069 Gtk::ProgressBar *autodetect_progress;
00070 Gtk::Button *mtr_abort, *toggle_settings, *start_autodetect;
00071 Gtk::Label *label_state, *label_beg, *label_end, *ok_mess, *fail_mess;
00072 Gtk::CheckButton *radio_speed, *radio_guessspeed;
00073 Gtk::Dialog *detection_failed;
00074
00075 Glib::ustring current_device, path;
00076
00077 void hide();
00078 bool check(bool unknown_state);
00079 void start_check();
00080 void stop_check();
00081 void toggle_settings_cb();
00082
00083
00084 void begin_changed();
00085 void dev_changed();
00086 void speed_changed();
00087 void timeout_changed();
00088 void autodetect_start();
00089 void prog_clicked(Glib::ustring filename);
00090 void abortation();
00091 void set_normal_state(bool state);
00092
00093
00094 MRMReCreator mrmc;
00095
00096 sigc::connection update_progress, check_dev;
00097
00098 std::list<std::string> speedlist;
00099 bool stop_button_pressed;
00100 bool port_ok;
00101 bool settings_visible;
00102 bool detected;
00103
00104
00105 public:
00111 MTRSetup(Glib::RefPtr<Gnome::Glade::Xml> gxml, Gtk::Dialog *d, Glib::ustring mtr_prog_path);
00112 ~MTRSetup(){};
00113
00114 void show();
00115 };
00116
00117 #endif