projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Append new segments to the end, not the beginning of the list
[pulseview.git]
/
pv
/
data
/
signalbase.cpp
diff --git
a/pv/data/signalbase.cpp
b/pv/data/signalbase.cpp
index 797bd456817e9e1cb0ef2d4c39e193acbe33b165..e500231b6e0404aeb75fbf5d603276e443bda1b5 100644
(file)
--- a/
pv/data/signalbase.cpp
+++ b/
pv/data/signalbase.cpp
@@
-40,6
+40,7
@@
namespace data {
const int SignalBase::ColourBGAlpha = 8 * 256 / 100;
const uint64_t SignalBase::ConversionBlockSize = 4096;
const int SignalBase::ColourBGAlpha = 8 * 256 / 100;
const uint64_t SignalBase::ConversionBlockSize = 4096;
+const uint32_t SignalBase::ConversionDelay = 1000; // 1 second
SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type) :
channel_(channel),
SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type) :
channel_(channel),
@@
-50,6
+51,11
@@
SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_
{
if (channel_)
internal_name_ = QString::fromStdString(channel_->name());
{
if (channel_)
internal_name_ = QString::fromStdString(channel_->name());
+
+ connect(&delayed_conversion_starter_, SIGNAL(timeout()),
+ this, SLOT(on_delayed_conversion_start()));
+ delayed_conversion_starter_.setSingleShot(true);
+ delayed_conversion_starter_.setInterval(ConversionDelay);
}
SignalBase::~SignalBase()
}
SignalBase::~SignalBase()
@@
-244,33
+250,33
@@
vector<double> SignalBase::get_conversion_thresholds(const ConversionType t,
{
vector<double> result;
ConversionType conv_type = t;
{
vector<double> result;
ConversionType conv_type = t;
-
in
t preset;
+
ConversionPrese
t preset;
// Use currently active conversion if no conversion type was supplied
if (conv_type == NoConversion)
conv_type = conversion_type_;
if (always_custom)
// Use currently active conversion if no conversion type was supplied
if (conv_type == NoConversion)
conv_type = conversion_type_;
if (always_custom)
- preset =
-1
;
+ preset =
NoPreset
;
else
preset = get_current_conversion_preset();
if (conv_type == A2LConversionByThreshold) {
double thr = 0;
else
preset = get_current_conversion_preset();
if (conv_type == A2LConversionByThreshold) {
double thr = 0;
- if (preset ==
-1
) {
+ if (preset ==
NoPreset
) {
auto thr_iter = conversion_options_.find("threshold_value");
if (thr_iter != conversion_options_.end())
thr = (thr_iter->second).toDouble();
}
auto thr_iter = conversion_options_.find("threshold_value");
if (thr_iter != conversion_options_.end())
thr = (thr_iter->second).toDouble();
}
- if (preset ==
0
)
+ if (preset ==
DynamicPreset
)
thr = (min_value_ + max_value_) * 0.5; // middle between min and max
thr = (min_value_ + max_value_) * 0.5; // middle between min and max
- if (preset == 1) thr = 0.9;
- if (preset == 2) thr = 1.8;
- if (preset == 3) thr = 2.5;
- if (preset == 4) thr = 1.5;
+ if (
(int)
preset == 1) thr = 0.9;
+ if (
(int)
preset == 2) thr = 1.8;
+ if (
(int)
preset == 3) thr = 2.5;
+ if (
(int)
preset == 4) thr = 1.5;
result.push_back(thr);
}
result.push_back(thr);
}
@@
-278,7
+284,7
@@
vector<double> SignalBase::get_conversion_thresholds(const ConversionType t,
if (conv_type == A2LConversionBySchmittTrigger) {
double thr_lo = 0, thr_hi = 0;
if (conv_type == A2LConversionBySchmittTrigger) {
double thr_lo = 0, thr_hi = 0;
- if (preset ==
-1
) {
+ if (preset ==
NoPreset
) {
auto thr_lo_iter = conversion_options_.find("threshold_value_low");
if (thr_lo_iter != conversion_options_.end())
thr_lo = (thr_lo_iter->second).toDouble();
auto thr_lo_iter = conversion_options_.find("threshold_value_low");
if (thr_lo_iter != conversion_options_.end())
thr_lo = (thr_lo_iter->second).toDouble();
@@
-288,17
+294,17
@@
vector<double> SignalBase::get_conversion_thresholds(const ConversionType t,
thr_hi = (thr_hi_iter->second).toDouble();
}
thr_hi = (thr_hi_iter->second).toDouble();
}
- if (preset ==
0
) {
+ if (preset ==
DynamicPreset
) {
const double amplitude = max_value_ - min_value_;
const double center = min_value_ + (amplitude / 2);
thr_lo = center - (amplitude * 0.15); // 15% margin
thr_hi = center + (amplitude * 0.15); // 15% margin
}
const double amplitude = max_value_ - min_value_;
const double center = min_value_ + (amplitude / 2);
thr_lo = center - (amplitude * 0.15); // 15% margin
thr_hi = center + (amplitude * 0.15); // 15% margin
}
- if (preset == 1) { thr_lo = 0.3; thr_hi = 1.2; }
- if (preset == 2) { thr_lo = 0.7; thr_hi = 2.5; }
- if (preset == 3) { thr_lo = 1.3; thr_hi = 3.7; }
- if (preset == 4) { thr_lo = 0.8; thr_hi = 2.0; }
+ if (
(int)
preset == 1) { thr_lo = 0.3; thr_hi = 1.2; }
+ if (
(int)
preset == 2) { thr_lo = 0.7; thr_hi = 2.5; }
+ if (
(int)
preset == 3) { thr_lo = 1.3; thr_hi = 3.7; }
+ if (
(int)
preset == 4) { thr_lo = 0.8; thr_hi = 2.0; }
result.push_back(thr_lo);
result.push_back(thr_hi);
result.push_back(thr_lo);
result.push_back(thr_hi);
@@
-332,18
+338,18
@@
vector< pair<QString, int> > SignalBase::get_conversion_presets() const
return presets;
}
return presets;
}
-
in
t SignalBase::get_current_conversion_preset() const
+
SignalBase::ConversionPrese
t SignalBase::get_current_conversion_preset() const
{
auto preset = conversion_options_.find("preset");
if (preset != conversion_options_.end())
{
auto preset = conversion_options_.find("preset");
if (preset != conversion_options_.end())
- return (
preset->second).toInt(
);
+ return (
ConversionPreset)((preset->second).toInt()
);
- return
-1
;
+ return
DynamicPreset
;
}
}
-void SignalBase::set_conversion_preset(
in
t id)
+void SignalBase::set_conversion_preset(
ConversionPrese
t id)
{
{
- conversion_options_["preset"] = id;
+ conversion_options_["preset"] =
(int)
id;
}
#ifdef ENABLE_DECODE
}
#ifdef ENABLE_DECODE
@@
-522,12
+528,18
@@
void SignalBase::conversion_thread_proc(QObject* segment)
} while (!conversion_interrupt_);
}
} while (!conversion_interrupt_);
}
-void SignalBase::start_conversion()
+void SignalBase::start_conversion(
bool delayed_start
)
{
{
+ if (delayed_start) {
+ delayed_conversion_starter_.start();
+ return;
+ }
+
stop_conversion();
if (converted_data_)
converted_data_->clear();
stop_conversion();
if (converted_data_)
converted_data_->clear();
+ samples_cleared();
if (conversion_is_a2l()) {
shared_ptr<Analog> analog_data = dynamic_pointer_cast<Analog>(data_);
if (conversion_is_a2l()) {
shared_ptr<Analog> analog_data = dynamic_pointer_cast<Analog>(data_);
@@
-568,8
+580,9
@@
void SignalBase::on_samples_added(QObject* segment, uint64_t start_sample,
// Notify the conversion thread since it's running
conversion_input_cond_.notify_one();
} else {
// Notify the conversion thread since it's running
conversion_input_cond_.notify_one();
} else {
- // Start the conversion thread
- start_conversion();
+ // Start the conversion thread unless the delay timer is running
+ if (!delayed_conversion_starter_.isActive())
+ start_conversion();
}
}
}
}
@@
-578,13
+591,12
@@
void SignalBase::on_samples_added(QObject* segment, uint64_t start_sample,
void SignalBase::on_min_max_changed(float min, float max)
{
void SignalBase::on_min_max_changed(float min, float max)
{
- (void)min;
- (void)max;
-
- // Restart conversion if one is enabled and uses an automatic threshold
+ // Restart conversion if one is enabled and uses a calculated threshold
if ((conversion_type_ != NoConversion) &&
if ((conversion_type_ != NoConversion) &&
- (get_current_conversion_preset() == 0))
- start_conversion();
+ (get_current_conversion_preset() == DynamicPreset))
+ start_conversion(true);
+
+ min_max_changed(min, max);
}
void SignalBase::on_capture_state_changed(int state)
}
void SignalBase::on_capture_state_changed(int state)
@@
-596,5
+608,10
@@
void SignalBase::on_capture_state_changed(int state)
}
}
}
}
+void SignalBase::on_delayed_conversion_start()
+{
+ start_conversion();
+}
+
} // namespace data
} // namespace pv
} // namespace data
} // namespace pv