RTXI  2.4
The Real-Time eXperiment Interface Documentation
oscilloscope.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  */
19 
20 /*
21  Oscilloscope namespace. The namespace works with
22  both Scope and Panel classes to instantiate an oscilloscope
23  plugin.
24  */
25 
26 #ifndef OSCILLOSCOPE_H
27 #define OSCILLOSCOPE_H
28 
29 #include <QtWidgets>
30 
31 #include <event.h>
32 #include <fifo.h>
33 #include <io.h>
34 #include <mutex.h>
35 #include <plugin.h>
36 #include <rt.h>
37 #include <settings.h>
38 
39 #include "scope.h"
40 
41 namespace Oscilloscope
42 {
43 
44 class SpinBox;
45 class CheckBox;
46 class Panel;
47 
48 class Plugin : public QObject, public ::Plugin::Object, public RT::Thread
49 {
50 
51  Q_OBJECT
52 
53  friend class Panel;
54 
55 public:
56  static Plugin *getInstance(void);
57 
58 public slots:
59  void createOscilloscopePanel(void);
60 
61 protected:
62  virtual void doDeferred(const Settings::Object::State &);
63  virtual void doLoad(const Settings::Object::State &);
64  virtual void doSave(Settings::Object::State &) const;
65 
66 private:
67  Plugin(void);
68  ~Plugin(void);
69  Plugin(const Plugin &) : QObject(), RT::Thread() {};
70  Plugin &operator=(const Plugin &)
71  {
72  return *getInstance();
73  };
74  static Plugin *instance;
75  void removeOscilloscopePanel(Panel *);
76 
77  // List to maintain multiple scopes
78  std::list<Panel *> panelList;
79 }; // Plugin
80 
81 class Panel : public QWidget, public RT::Thread, public virtual Settings::Object, public Event::Handler
82 {
83 
84  Q_OBJECT
85 
86  friend class Scope;
87 
88 public:
89  Panel(QWidget * = NULL);
90  virtual ~Panel(void);
91  void execute(void);
92  bool setInactiveSync(void);
93  void flushFifo(void);
94  void adjustDataSize(void);
95  void doDeferred(const Settings::Object::State &);
96  void doLoad(const Settings::Object::State &);
97  void doSave(Settings::Object::State &) const;
98  void receiveEvent(const ::Event::Object *);
99 
100 public slots:
101  void timeoutEvent(void);
102  void togglePause(void);
103 
104 protected:
105 
106 private slots:
107  void showChannelTab(void);
108  void showDisplayTab(void);
109  void buildChannelList(void);
110  void screenshot(void);
111  void apply(void);
112  void showTab(int);
113  void activateChannel(bool);
114 
115 private:
116  QMdiSubWindow *subWindow;
117 
118  // Tab Widget
119  QTabWidget *tabWidget;
120 
121  // Create scope
122  Scope *scopeWindow;
123 
124  // Create curve element
125  QwtPlotCurve *curve;
126 
127  // Functions to initialize and
128  // apply changes made in tabs
129  void applyChannelTab(void);
130  void applyDisplayTab(void);
131  QWidget *createChannelTab(QWidget *parent);
132  QWidget *createDisplayTab(QWidget *parent);
133 
134  // Group and layout information
135  QVBoxLayout *layout;
136  QWidget *scopeGroup;
137  QGroupBox *setBttnGroup;
138 
139  // Properties
140  QSpinBox *ratesSpin;
141  QLineEdit *sizesEdit;
142  QButtonGroup *trigsGroup;
143  QComboBox *timesList;
144  QComboBox *trigsChanList;
145  QComboBox *trigsThreshList;
146  QSpinBox *refreshsSpin;
147  QLineEdit *trigsThreshEdit;
148  QLineEdit *trigWindowEdit;
149  QComboBox *trigWindowList;
150 
151  // Lists
152  QComboBox *blocksList;
153  QComboBox *typesList;
154  QComboBox *channelsList;
155  QComboBox *colorsList;
156  QComboBox *offsetsList;
157  QComboBox *scalesList;
158  QComboBox *stylesList;
159  QComboBox *widthsList;
160  QLineEdit *offsetsEdit;
161 
162  // Buttons
163  QPushButton *pauseButton;
164  QPushButton *settingsButton;
165  QPushButton *applyButton;
166  QPushButton *activateButton;
167 
168  Fifo fifo;
169  std::vector<IO::Block *> blocks;
170  size_t counter;
171  size_t downsample_rate;
172 }; // Panel
173 }; // Oscilloscope
174 
175 #endif // OSCILLOSCOPE_H
Oscilloscope::Plugin::doSave
virtual void doSave(Settings::Object::State &) const
Definition: oscilloscope.cpp:107
Oscilloscope::Panel::setInactiveSync
bool setInactiveSync(void)
Definition: oscilloscope.cpp:1179
settings.h
Oscilloscope
Definition: oscilloscope.h:41
Plugin::Object
Definition: plugin.h:145
Oscilloscope::Panel::Panel
Panel(QWidget *=NULL)
Definition: oscilloscope.cpp:1001
Oscilloscope::Plugin::Panel
friend class Panel
Definition: oscilloscope.h:53
fifo.h
plugin.h
Oscilloscope::Plugin::createOscilloscopePanel
void createOscilloscopePanel(void)
Definition: oscilloscope.cpp:79
RT
Realtime Oriented Classes.
Definition: rt.h:34
Oscilloscope::Panel::timeoutEvent
void timeoutEvent(void)
Definition: oscilloscope.cpp:1203
Oscilloscope::Panel::receiveEvent
void receiveEvent(const ::Event::Object *)
Definition: oscilloscope.cpp:115
Oscilloscope::Panel::doLoad
void doLoad(const Settings::Object::State &)
Definition: oscilloscope.cpp:1249
event.h
Scope
Definition: scope.h:52
Oscilloscope::Panel::adjustDataSize
void adjustDataSize(void)
Definition: oscilloscope.cpp:1195
Oscilloscope::Plugin::getInstance
static Plugin * getInstance(void)
Definition: oscilloscope.cpp:1312
Event::Handler
Definition: event.h:256
scope.h
Oscilloscope::Panel::execute
void execute(void)
Definition: oscilloscope.cpp:1107
Fifo
Definition: fifo.h:31
Oscilloscope::Panel::togglePause
void togglePause(void)
Definition: oscilloscope.cpp:1174
rt.h
mutex.h
Oscilloscope::Panel::doSave
void doSave(Settings::Object::State &) const
Definition: oscilloscope.cpp:1268
Oscilloscope::Panel::flushFifo
void flushFifo(void)
Definition: oscilloscope.cpp:1188
Settings::Object
Definition: settings.h:43
Settings::Object::State
Definition: settings.h:62
Plugin
Classes associated with the loading/unloading of binaries at run-time.
Definition: plugin.h:35
RT::Thread
Definition: rt.h:561
io.h
Oscilloscope::Plugin::doDeferred
virtual void doDeferred(const Settings::Object::State &)
Definition: oscilloscope.cpp:90
Oscilloscope::Panel::~Panel
virtual ~Panel(void)
Definition: oscilloscope.cpp:1099
Oscilloscope::Panel::doDeferred
void doDeferred(const Settings::Object::State &)
Definition: oscilloscope.cpp:1214
Oscilloscope::Plugin::doLoad
virtual void doLoad(const Settings::Object::State &)
Definition: oscilloscope.cpp:97
Oscilloscope::Panel
Definition: oscilloscope.h:81
RT::Thread::Thread
Thread(Priority p=DefaultPriority)
Definition: rt.cpp:141