ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
device.h
Go to the documentation of this file.
1 
9 #ifndef DEVICE_WDG_H
10 #define DEVICE_WDG_H
11 
12 #include <rad/smAdapter.hpp>
14 #include <fcf/gui/wdglib/spinner.h>
15 
16 #include <QWidget>
17 #include <QtWidgets/QLabel>
18 #include <QObject>
19 
20 
21 struct CommonUi {
22 public:
23 
24  explicit CommonUi() :
25  m_spinner(nullptr) {};
26 
27  void SetName(QLabel* name) {
28  m_name = name;
29  }
30 
31  QLabel* GetName() {
32  return m_name;
33  }
34 
35  void SetEnable(QCheckBox* enable) {
36  m_enable = enable;
37  }
38 
39  QCheckBox* GetEnable() {
40  return m_enable;
41  }
42 
43  void SetSpinner(Spinner* spinner) {
44  m_spinner = spinner;
45  }
46 
48  return m_spinner;
49  }
50 
51  void SetState(QLabel* state) {
52  m_state = state;
53  }
54 
55  QLabel* GetState() {
56  return m_state;
57  }
58 
59  void SetSubstate(QLabel* substate) {
60  m_substate = substate;
61  }
62 
63  QLabel* GetSubstate() {
64  return m_substate;
65  }
66 
67  void SetSim(QLabel* sim) {
68  m_sim = sim;
69  }
70 
71  QLabel* GetSim() {
72  return m_sim;
73  }
74 
75  void SetLocal(QLabel* local) {
76  m_local = local;
77  }
78 
79  QLabel* GetLocal() {
80  return m_local;
81  }
82 
83  void SetError(QLabel* error) {
84  m_error = error;
85  }
86 
87  QLabel* GetError() {
88  return m_error;
89  }
90 
91  void SetFrame(QFrame* frame) {
92  m_frame = frame;
93  }
94 
95  QFrame* GetFrame() {
96  return m_frame;
97  }
98 
99 private:
100  QLabel* m_name;
101  QCheckBox* m_enable;
102  Spinner* m_spinner;
103  QLabel* m_state;
104  QLabel* m_substate;
105  QLabel* m_sim;
106  QLabel* m_local;
107  QLabel* m_error;
108  QFrame* m_frame;
109 
110 };
111 
112 class DeviceWdg : public AbstractDevice {
113  Q_OBJECT
114 public:
115  explicit DeviceWdg(QWidget *parent, std::string name, int cmd_timeout);
116  virtual ~DeviceWdg();
117  std::string GetName();
118  void Select();
119  void Deselect();
120  bool IsSelected();
121  virtual void Stop();
122  virtual void GetDbAttributes(std::string server_id, std::vector<std::string>& vector);
123  virtual void UpdateData(QList<QVariant>& data_list);
124  virtual void SetEnable(bool flag);
125 
126 protected:
127  void SetupCommonUi();
128  bool IsSimulated();
129 
130 signals:
131  void TriggerSetup(QString);
132 
133 public slots:
134  void SetActive(int index);
135  void UpdateState(int state);
136  bool UpdateSubstate(int substate);
137  void UpdateSpinner(int substate);
138  void UpdateErrorMsg(std::string msg);
139  void HandleSetupButton();
140 
141 
142 protected:
144  std::string m_name;
148 
149 };
150 
151 #endif // DEVICE_WDG_H
QLabel * GetName()
Definition: device.h:31
virtual void GetDbAttributes(std::string server_id, std::vector< std::string > &vector)
Definition: device.cpp:167
std::string m_name
Definition: device.h:144
QLabel * GetState()
Definition: device.h:55
void UpdateState(int state)
Definition: device.cpp:132
bool m_simulated
Definition: device.h:146
void SetEnable(QCheckBox *enable)
Definition: device.h:35
Definition: device.h:112
Definition: spinner.h:29
void SetSim(QLabel *sim)
Definition: device.h:67
virtual ~DeviceWdg()
Definition: device.cpp:30
int m_cmd_timeout
Definition: device.h:145
QCheckBox * GetEnable()
Definition: device.h:39
void SetLocal(QLabel *local)
Definition: device.h:75
CommonUi m_ui
Definition: device.h:147
bool IsSelected()
Definition: device.cpp:65
void TriggerSetup(QString)
QLabel * GetSim()
Definition: device.h:71
void Deselect()
Definition: device.cpp:61
virtual void UpdateData(QList< QVariant > &data_list)
Definition: device.cpp:195
DeviceWdg(QWidget *parent, std::string name, int cmd_timeout)
Definition: device.cpp:23
QTimer * m_spinner_timer
Definition: device.h:143
void HandleSetupButton()
Definition: device.cpp:162
QLabel * GetSubstate()
Definition: device.h:63
WDGLIB AbstractDevice class declaration file.
void SetError(QLabel *error)
Definition: device.h:83
bool IsSimulated()
Definition: device.cpp:284
void SetSpinner(Spinner *spinner)
Definition: device.h:43
QFrame * GetFrame()
Definition: device.h:95
void Select()
Definition: device.cpp:57
void UpdateErrorMsg(std::string msg)
Definition: device.cpp:147
bool UpdateSubstate(int substate)
Definition: device.cpp:75
Spinner * GetSpinner()
Definition: device.h:47
Definition: abstractDevice.h:21
QLabel * GetLocal()
Definition: device.h:79
void UpdateSpinner(int substate)
Definition: device.cpp:108
void SetupCommonUi()
Definition: device.cpp:34
void SetSubstate(QLabel *substate)
Definition: device.h:59
void SetState(QLabel *state)
Definition: device.h:51
QLabel * GetError()
Definition: device.h:87
void SetName(QLabel *name)
Definition: device.h:27
std::string GetName()
Definition: device.cpp:53
virtual void SetEnable(bool flag)
Definition: device.cpp:237
void SetActive(int index)
Definition: device.cpp:70
Definition: device.h:21
virtual void Stop()
Definition: device.cpp:157
CommonUi()
Definition: device.h:24
void SetFrame(QFrame *frame)
Definition: device.h:91