00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _SensorLogger_h
00022 #define _SensorLogger_h
00023
00024 #include <tqdom.h>
00025 #include <tqlabel.h>
00026 #include <tqlineedit.h>
00027 #include <tqlistview.h>
00028 #include <tqpopupmenu.h>
00029 #include <tqspinbox.h>
00030 #include <tqstring.h>
00031
00032 #include <SensorDisplay.h>
00033
00034 #include "SensorLoggerDlg.h"
00035
00036 #define NONE -1
00037
00038 class SensorLoggerSettings;
00039
00040 class SLListViewItem : public QListViewItem
00041 {
00042 public:
00043 SLListViewItem(TQListView *parent = 0);
00044
00045 void setTextColor(const TQColor& color) { textColor = color; }
00046
00047 void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment) {
00048 TQColorGroup cgroup(cg);
00049 cgroup.setColor(TQColorGroup::Text, textColor);
00050 TQListViewItem::paintCell(p, cgroup, column, width, alignment);
00051
00052 }
00053
00054 void paintFocus(TQPainter *, const TQColorGroup, const TQRect) {}
00055
00056 private:
00057 TQColor textColor;
00058 };
00059
00060 class LogSensor : public TQObject, public KSGRD::SensorClient
00061 {
00062 Q_OBJECT
00063 public:
00064 LogSensor(TQListView *parent);
00065 ~LogSensor(void);
00066
00067 void answerReceived(int id, const TQString& answer);
00068
00069 void setHostName(const TQString& name) { hostName = name; lvi->setText(3, name); }
00070 void setSensorName(const TQString& name) { sensorName = name; lvi->setText(2, name); }
00071 void setFileName(const TQString& name)
00072 {
00073 fileName = name;
00074 lvi->setText(4, name);
00075 }
00076 void setUpperLimitActive(bool value) { upperLimitActive = value; }
00077 void setLowerLimitActive(bool value) { lowerLimitActive = value; }
00078 void setUpperLimit(double value) { upperLimit = value; }
00079 void setLowerLimit(double value) { lowerLimit = value; }
00080
00081 void setTimerInterval(int interval) {
00082 timerInterval = interval;
00083
00084 if (timerID != NONE)
00085 {
00086 timerOff();
00087 timerOn();
00088 }
00089
00090 lvi->setText(1, TQString("%1").arg(interval));
00091 }
00092
00093 TQString getSensorName(void) { return sensorName; }
00094 TQString getHostName(void) { return hostName; }
00095 TQString getFileName(void) { return fileName; }
00096 int getTimerInterval(void) { return timerInterval; }
00097 bool getUpperLimitActive(void) { return upperLimitActive; }
00098 bool getLowerLimitActive(void) { return lowerLimitActive; }
00099 double getUpperLimit(void) { return upperLimit; }
00100 double getLowerLimit(void) { return lowerLimit; }
00101 TQListViewItem* getListViewItem(void) { return lvi; }
00102
00103 public slots:
00104 void timerOff()
00105 {
00106 killTimer(timerID);
00107 timerID = NONE;
00108 }
00109
00110 void timerOn()
00111 {
00112 timerID = startTimer(timerInterval * 1000);
00113 }
00114
00115 bool isLogging() { return timerID != NONE; }
00116
00117 void startLogging(void);
00118 void stopLogging(void);
00119
00120 protected:
00121 virtual void timerEvent(TQTimerEvent*);
00122
00123 private:
00124 TQListView* monitor;
00125 SLListViewItem* lvi;
00126 TQPixmap pixmap_running;
00127 TQPixmap pixmap_waiting;
00128 TQString sensorName;
00129 TQString hostName;
00130 TQString fileName;
00131
00132 int timerInterval;
00133 int timerID;
00134
00135 bool lowerLimitActive;
00136 bool upperLimitActive;
00137
00138 double lowerLimit;
00139 double upperLimit;
00140 };
00141
00142 class SensorLogger : public KSGRD::SensorDisplay
00143 {
00144 Q_OBJECT
00145 public:
00146 SensorLogger(TQWidget *parent = 0, const char *name = 0, const TQString& title = 0);
00147 ~SensorLogger(void);
00148
00149 bool addSensor(const TQString& hostName, const TQString& sensorName, const TQString& sensorType,
00150 const TQString& sensorDescr);
00151
00152 bool editSensor(LogSensor*);
00153
00154 void answerReceived(int id, const TQString& answer);
00155 void resizeEvent(TQResizeEvent*);
00156
00157 bool restoreSettings(TQDomElement& element);
00158 bool saveSettings(TQDomDocument& doc, TQDomElement& element, bool save = true);
00159
00160 void configureSettings(void);
00161
00162 virtual bool hasSettingsDialog() const
00163 {
00164 return (true);
00165 }
00166
00167 public slots:
00168 void applySettings();
00169 void applyStyle();
00170 void RMBClicked(TQListViewItem*, const TQPoint&, int);
00171
00172 protected:
00173 LogSensor* getLogSensor(TQListViewItem*);
00174
00175 private:
00176 TQListView* monitor;
00177
00178 TQPtrList<LogSensor> logSensors;
00179
00180 SensorLoggerDlg *sld;
00181 SensorLoggerSettings *sls;
00182 };
00183
00184 #endif // _SensorLogger_h