NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
service.h
1 // Wrapper for service calls
2 // Author: Dmytro Pavlichenko dm.mark999@gmail.com
3 
4 #ifndef SERVICE_H
5 #define SERVICE_H
6 
7 #include <string>
8 #include <QDoubleSpinBox>
9 #include <QLineEdit>
10 
11 namespace control_widget
12 {
13 
14 namespace service
15 {
16 
17  namespace color
18  {
19  static const QString failure = QString("Red");
20  static const QString success = QString("Green");
21  static const QString input = QString("Blue");
22  static const QString output = QString("MediumVioletRed");
23  };
24 
25 // Base class
26 class Service
27 {
28 public:
29  Service(std::string name);
30  virtual ~Service();
31 
32  virtual bool call(QStringList &output);
33 
34 protected:
35  template<typename Req, typename Res>
36  bool callService(Req &request, Res &response, QStringList &output);
37 
38  template<typename Req>
39  bool callService(Req &request, QStringList &output);
40 
41  void prependTime(QString &text) const;
42  QString separator() const;
43  void setHtmlColor(QString &text, QString color) const;
44 
45 protected:
46  std::string serviceName;
47 };
48 
49 
50 class ResetConfig : public Service
51 {
52 public:
53  ResetConfig(std::string name);
54  bool call(QStringList &output);
55 };
56 
57 class SaveConfig : public Service
58 {
59 public:
60  SaveConfig(std::string name);
61  bool call(QStringList &output);
62 };
63 
64 class AttEstCalib : public Service
65 {
66 public:
67  AttEstCalib(std::string name);
68  bool call(QStringList &output);
69 };
70 
71 class ShowDeadVars : public Service
72 {
73 public:
74  ShowDeadVars(std::string name, QLineEdit *path_);
75  bool call(QStringList &output);
76 
77 private:
78  QLineEdit *path;
79 };
80 
81 class MagCalib2D : public Service
82 {
83 public:
84  MagCalib2D(std::string name);
85  bool call(QStringList &output);
86 };
87 
88 class MagCalib3D : public Service
89 {
90 public:
91  MagCalib3D(std::string name);
92  bool call(QStringList &output);
93 };
94 
95 class MagCalibShow : public Service
96 {
97 public:
98  MagCalibShow(std::string name);
99  bool call(QStringList &output);
100 };
101 
102 class WarpAddPoint : public Service
103 {
104 public:
105  WarpAddPoint(std::string name, float value_); // value_ must be in degrees
106  bool call(QStringList &output);
107 
108 private:
109  float value;
110 };
111 
112 class SetOdom : public Service
113 {
114 public:
115  SetOdom(std::string name, QDoubleSpinBox *x_, QDoubleSpinBox *y_, QDoubleSpinBox *theta_);
116  bool call(QStringList &output);
117 
118 private:
119  QDoubleSpinBox *x;
120  QDoubleSpinBox *y;
121  QDoubleSpinBox *theta;
122 };
123 
124 class ReadOffset : public Service
125 {
126 public:
127  ReadOffset(std::string name, QLineEdit *joint_);
128  bool call(QStringList &output);
129 
130 private:
131  QLineEdit *joint;
132 };
133 
134 class UseLastServerIP : public Service
135 {
136 public:
137  UseLastServerIP(std::string name);
138  bool call(QStringList &output);
139 };
140 
141 class Empty : public Service
142 {
143 public:
144  Empty(std::string name);
145  bool call(QStringList &output);
146 };
147 
148 }
149 
150 }
151 
152 #endif