-
Notifications
You must be signed in to change notification settings - Fork 2
/
widget.hpp
153 lines (129 loc) · 3.35 KB
/
widget.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
Copyright (C) 2011 Georgia Institute of Technology
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QComboBox>
#include <string>
#include <rtxi/gen/gen_biphase.h>
#include <rtxi/gen/gen_mono.h>
#include <rtxi/gen/gen_saw.h>
#include <rtxi/gen/gen_sine.h>
#include <rtxi/gen/gen_zap.h>
#include <rtxi/widgets.hpp>
namespace SigGen
{
constexpr std::string_view MODULE_NAME = "Signal Generator";
namespace WAVEMODE
{
enum mode_t : int64_t
{
SINE = 0,
MONOSQUARE,
BISQUARE,
SAWTOOTH,
ZAP,
};
} // namespace WAVEMODE
enum PARAMETER : Widgets::Variable::Id
{
SIGNAL_WAVEFORM = 0,
DELAY,
WIDTH,
FREQ,
AMPLITUDE,
ZAP_MAX_FREQ,
ZAP_DURATION,
};
inline std::vector<Widgets::Variable::Info> get_default_vars()
{
return {
{PARAMETER::SIGNAL_WAVEFORM,
"Signal Waveform",
"The current type of signal being generated. Current types are sine, "
"monosquare, bisquare, sawtooth, and zap",
Widgets::Variable::INT_PARAMETER,
int64_t{0}},
{PARAMETER::DELAY,
"Delay (s)",
"Delay (s)",
Widgets::Variable::DOUBLE_PARAMETER,
1.0},
{PARAMETER::WIDTH,
"Width (s)",
"Width (s)",
Widgets::Variable::DOUBLE_PARAMETER,
1.0},
{PARAMETER::FREQ,
"Freq (Hz)",
"Freq (Hz), also used as minimum ZAP frequency",
Widgets::Variable::DOUBLE_PARAMETER,
1.0},
{PARAMETER::AMPLITUDE,
"Amplitude (V)",
"Amplitude (V)",
Widgets::Variable::DOUBLE_PARAMETER,
1.0},
{PARAMETER::ZAP_MAX_FREQ,
"ZAP max Freq (Hz)",
"Maximum ZAP frequency",
Widgets::Variable::DOUBLE_PARAMETER,
20.0},
{PARAMETER::ZAP_DURATION,
"ZAP duration (s)",
"ZAP duration (s)",
Widgets::Variable::DOUBLE_PARAMETER,
10.0}
};
}
inline std::vector<IO::channel_t> get_default_channels()
{
return {
{"Signal Generator Output", "Signal Generator Output", IO::OUTPUT}};
}
class Panel : public Widgets::Panel
{
Q_OBJECT
public:
Panel(QMainWindow* main_window, Event::Manager* ev_manager);
void customizeGUI();
public slots:
void refresh() override;
private:
// QT components
QPushButton* sineButton;
QComboBox* waveShape;
private slots:
void updateMode(int);
};
class Component : public Widgets::Component
{
public:
explicit Component(Widgets::Plugin* hplugin);
void execute() override;
private:
void initParameters();
void initStimulus(); // creates SigGen stimuli
GeneratorSine sineWave;
GeneratorMono monoWave;
GeneratorBiphase biWave;
GeneratorSaw sawWave;
GeneratorZap zapWave;
Generator* current_generator = nullptr;
double dt;
mode_t mode;
};
class Plugin : public Widgets::Plugin
{
public:
explicit Plugin(Event::Manager* ev_manager);
};
} // namespace SigGen