forked from Ivasoft/DSView
Add sample duration setting replace of sample count
Improve channel control panel under DSO mode
This commit is contained in:
@@ -184,6 +184,8 @@ void MainWindow::setup_ui()
|
||||
SLOT(hide_calibration()));
|
||||
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view,
|
||||
SLOT(set_trig_pos(int)));
|
||||
connect(_sampling_bar, SIGNAL(hori_res_changed(double)), _view,
|
||||
SLOT(hori_res_changed(double)));
|
||||
|
||||
setIconSize(QSize(40,40));
|
||||
addToolBar(_sampling_bar);
|
||||
@@ -567,7 +569,8 @@ void MainWindow::capture_state_changed(int state)
|
||||
_sampling_bar->set_sampling(state == SigSession::Running);
|
||||
_view->on_state_changed(state != SigSession::Running);
|
||||
|
||||
if (_session.get_device()->dev_inst()->mode != DSO) {
|
||||
if (_session.get_device()->dev_inst()->mode != DSO ||
|
||||
_session.get_instant()) {
|
||||
_sampling_bar->enable_toggle(state != SigSession::Running);
|
||||
_trig_bar->enable_toggle(state != SigSession::Running);
|
||||
//_measure_dock->widget()->setEnabled(state != SigSession::Running);
|
||||
@@ -754,8 +757,6 @@ bool MainWindow::load_session(QString name)
|
||||
_session.get_device()->set_config(NULL, NULL, info->key, g_variant_new_string(sessionObj[info->name].toString().toUtf8()));
|
||||
}
|
||||
}
|
||||
_sampling_bar->update_record_length();
|
||||
_sampling_bar->update_sample_rate();
|
||||
|
||||
// load channel settings
|
||||
for (const GSList *l = _session.get_device()->dev_inst()->channels; l; l = l->next) {
|
||||
@@ -782,7 +783,7 @@ bool MainWindow::load_session(QString name)
|
||||
if (!isEnabled)
|
||||
probe->enabled = false;
|
||||
}
|
||||
_sampling_bar->update_record_length();
|
||||
_sampling_bar->update_sample_rate_selector();
|
||||
_trigger_widget->device_updated();
|
||||
|
||||
//_session.init_signals();
|
||||
|
||||
@@ -510,14 +510,6 @@ void StoreSession::export_proc(shared_ptr<data::Snapshot> snapshot)
|
||||
g_hash_table_insert(params, (char*)"filename", filenameGVariant);
|
||||
GVariant* typeGVariant = g_variant_new_int16(channel_type);
|
||||
g_hash_table_insert(params, (char*)"type", typeGVariant);
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
GVariant* timebaseGVariant = g_variant_new_uint64(dsoSig->get_hDialValue());
|
||||
g_hash_table_insert(params, (char*)"timebase", timebaseGVariant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct sr_output output;
|
||||
output.module = (sr_output_module*) _outModule;
|
||||
|
||||
@@ -49,31 +49,8 @@ using std::string;
|
||||
namespace pv {
|
||||
namespace toolbars {
|
||||
|
||||
const uint64_t SamplingBar::RecordLengths[19] = {
|
||||
1000,
|
||||
2000,
|
||||
4000,
|
||||
8000,
|
||||
10000,
|
||||
20000,
|
||||
40000,
|
||||
80000,
|
||||
100000,
|
||||
200000,
|
||||
400000,
|
||||
800000,
|
||||
1000000,
|
||||
2000000,
|
||||
4000000,
|
||||
8000000,
|
||||
10000000,
|
||||
20000000,
|
||||
40000000,
|
||||
};
|
||||
|
||||
const QString SamplingBar::RLEString = "(RLE)";
|
||||
|
||||
const uint64_t SamplingBar::DefaultRecordLength = 1000000;
|
||||
const QString SamplingBar::RLEString = tr("(RLE)");
|
||||
const QString SamplingBar::DIVString = tr(" / div");
|
||||
|
||||
SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
|
||||
QToolBar("Sampling Bar", parent),
|
||||
@@ -203,7 +180,6 @@ void SamplingBar::set_device_list(
|
||||
_device_selector.setCurrentIndex(selected_index);
|
||||
|
||||
update_sample_rate_selector();
|
||||
update_sample_count_selector();
|
||||
|
||||
_updating_device_selector = false;
|
||||
}
|
||||
@@ -238,9 +214,7 @@ void SamplingBar::on_configure()
|
||||
ret = dlg.exec();
|
||||
if (ret == QDialog::Accepted) {
|
||||
device_updated();
|
||||
update_sample_count_selector();
|
||||
update_sample_rate_selector();
|
||||
commit_sample_rate();
|
||||
|
||||
GVariant* gvar;
|
||||
if (dev_inst->dev_inst()->mode == DSO) {
|
||||
@@ -269,13 +243,13 @@ void SamplingBar::on_configure()
|
||||
bool test = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
if (test) {
|
||||
update_sample_count_selector_value();
|
||||
update_sample_rate_selector_value();
|
||||
_sample_count.setDisabled(true);
|
||||
_sample_rate.setDisabled(true);
|
||||
} else if (dev_inst->dev_inst()->mode != DSO) {
|
||||
} else {
|
||||
_sample_count.setDisabled(false);
|
||||
_sample_rate.setDisabled(false);
|
||||
if (dev_inst->dev_inst()->mode != DSO)
|
||||
_sample_rate.setDisabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,48 +278,6 @@ void SamplingBar::zero_adj()
|
||||
on_run_stop();
|
||||
}
|
||||
|
||||
uint64_t SamplingBar::get_record_length() const
|
||||
{
|
||||
const int index = _sample_count.currentIndex();
|
||||
if (index < 0)
|
||||
return 0;
|
||||
|
||||
return _sample_count.itemData(index).value<uint64_t>();
|
||||
}
|
||||
|
||||
void SamplingBar::set_record_length(uint64_t length)
|
||||
{
|
||||
for (int i = 0; i < _sample_count.count(); i++) {
|
||||
if (length == _sample_count.itemData(
|
||||
i).value<uint64_t>()) {
|
||||
_sample_count.setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::update_record_length()
|
||||
{
|
||||
disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
|
||||
update_sample_count_selector();
|
||||
|
||||
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_rate()
|
||||
{
|
||||
disconnect(&_sample_rate, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplerate_sel(int)));
|
||||
|
||||
update_sample_rate_selector();
|
||||
|
||||
connect(&_sample_rate, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplerate_sel(int)));
|
||||
}
|
||||
|
||||
bool SamplingBar::get_sampling() const
|
||||
{
|
||||
return _sampling;
|
||||
@@ -393,25 +325,10 @@ void SamplingBar::set_sample_rate(uint64_t sample_rate)
|
||||
i).value<uint64_t>();
|
||||
if (sample_rate >= cur_index_sample_rate) {
|
||||
_sample_rate.setCurrentIndex(i);
|
||||
// commit the samplerate
|
||||
commit_sample_rate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::set_sample_limit(uint64_t sample_limit)
|
||||
{
|
||||
for (int i = 0; i < _sample_count.count(); i++) {
|
||||
uint64_t cur_index_sample_limit = _sample_count.itemData(
|
||||
i).value<uint64_t>();
|
||||
if (sample_limit <= cur_index_sample_limit) {
|
||||
_sample_count.setCurrentIndex(i);
|
||||
// commit the samplecount
|
||||
commit_sample_count();
|
||||
break;
|
||||
}
|
||||
}
|
||||
commit_settings();
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_rate_selector()
|
||||
@@ -468,6 +385,8 @@ void SamplingBar::update_sample_rate_selector()
|
||||
update_sample_rate_selector_value();
|
||||
connect(&_sample_rate, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplerate_sel(int)));
|
||||
|
||||
update_sample_count_selector();
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_rate_selector_value()
|
||||
@@ -480,96 +399,35 @@ void SamplingBar::update_sample_rate_selector_value()
|
||||
assert(!_updating_sample_rate);
|
||||
_updating_sample_rate = true;
|
||||
|
||||
//for (int i = 0; i < _sample_rate.count(); i++)
|
||||
for (int i = _sample_rate.count() - 1; i >= 0; i--) {
|
||||
if (samplerate >= _sample_rate.itemData(
|
||||
i).value<uint64_t>()) {
|
||||
_sample_rate.setCurrentIndex(i);
|
||||
break;
|
||||
if (samplerate != _sample_rate.itemData(
|
||||
_sample_rate.currentIndex()).value<uint64_t>()) {
|
||||
for (int i = _sample_rate.count() - 1; i >= 0; i--) {
|
||||
if (samplerate >= _sample_rate.itemData(
|
||||
i).value<uint64_t>()) {
|
||||
_sample_rate.setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_updating_sample_rate = false;
|
||||
}
|
||||
|
||||
void SamplingBar::commit_sample_rate()
|
||||
{
|
||||
uint64_t sample_rate = 0;
|
||||
|
||||
if (_updating_sample_rate)
|
||||
return;
|
||||
|
||||
assert(!_updating_sample_rate);
|
||||
_updating_sample_rate = true;
|
||||
|
||||
const int index = _sample_rate.currentIndex();
|
||||
if (index >= 0)
|
||||
sample_rate = _sample_rate.itemData(
|
||||
index).value<uint64_t>();
|
||||
|
||||
if (sample_rate == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
get_selected_device()->set_config(NULL, NULL,
|
||||
SR_CONF_SAMPLERATE,
|
||||
g_variant_new_uint64(sample_rate));
|
||||
|
||||
_updating_sample_rate = false;
|
||||
}
|
||||
|
||||
void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
uint64_t sample_count = 0;
|
||||
|
||||
if (index >= 0)
|
||||
sample_count = _sample_count.itemData(
|
||||
index).value<uint64_t>();
|
||||
|
||||
boost::shared_ptr<pv::device::DevInst> _devInst = get_selected_device();
|
||||
assert(_devInst);
|
||||
|
||||
if (_devInst->dev_inst()->mode != DSO) {
|
||||
|
||||
// Set the sample count
|
||||
_devInst->set_config(NULL, NULL,
|
||||
SR_CONF_LIMIT_SAMPLES,
|
||||
g_variant_new_uint64(sample_count));
|
||||
|
||||
sample_count_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::on_samplerate_sel(int index)
|
||||
{
|
||||
uint64_t sample_rate = 0;
|
||||
|
||||
if (index >= 0)
|
||||
sample_rate = _sample_rate.itemData(
|
||||
index).value<uint64_t>();
|
||||
|
||||
boost::shared_ptr<pv::device::DevInst> dev_inst = get_selected_device();
|
||||
assert(dev_inst);
|
||||
|
||||
// Get last samplerate
|
||||
//last_sample_rate = get_selected_device()->get_sample_rate();
|
||||
|
||||
if (dev_inst->dev_inst()->mode != DSO) {
|
||||
// Set the samplerate
|
||||
get_selected_device()->set_config(NULL, NULL,
|
||||
SR_CONF_SAMPLERATE,
|
||||
g_variant_new_uint64(sample_rate));
|
||||
}
|
||||
(void)index;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst->dev_inst()->mode != DSO)
|
||||
update_sample_count_selector();
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_count_selector()
|
||||
{
|
||||
GVariant *gvar_dict, *gvar_list;
|
||||
const uint64_t *elements = NULL;
|
||||
gsize num_elements;
|
||||
bool stream_mode = false;
|
||||
uint64_t hw_depth = 0;
|
||||
uint64_t sw_depth;
|
||||
double pre_duration = SR_SEC(1);
|
||||
double duration;
|
||||
|
||||
if (_updating_sample_count)
|
||||
return;
|
||||
@@ -577,21 +435,10 @@ void SamplingBar::update_sample_count_selector()
|
||||
disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
return;
|
||||
|
||||
assert(!_updating_sample_count);
|
||||
_updating_sample_count = true;
|
||||
|
||||
if (!(gvar_dict = dev_inst->list_config(NULL, SR_CONF_LIMIT_SAMPLES)))
|
||||
{
|
||||
_sample_count.clear();
|
||||
_sample_count.show();
|
||||
_updating_sample_count = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
if (gvar != NULL) {
|
||||
stream_mode = g_variant_get_boolean(gvar);
|
||||
@@ -603,47 +450,87 @@ void SamplingBar::update_sample_count_selector()
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
if ((gvar_list = g_variant_lookup_value(gvar_dict,
|
||||
"samplecounts", G_VARIANT_TYPE("at"))))
|
||||
{
|
||||
elements = (const uint64_t *)g_variant_get_fixed_array(
|
||||
gvar_list, &num_elements, sizeof(uint64_t));
|
||||
_sample_count.clear();
|
||||
|
||||
if (dev_inst->dev_inst()->mode == LOGIC) {
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
sw_depth = elements[num_elements - 1];
|
||||
sw_depth = LogicMaxSWDepth64;
|
||||
#elif defined(__i386) || defined(_M_IX86)
|
||||
int ch_num = _session.get_ch_num(SR_CHANNEL_LOGIC);
|
||||
if (ch_num <= 0)
|
||||
sw_depth = SR_GB(8);
|
||||
sw_depth = LogicMaxSWDepth32;
|
||||
else
|
||||
sw_depth = SR_GB(8) / ch_num;
|
||||
sw_depth = LogicMaxSWDepth32 / ch_num;
|
||||
#endif
|
||||
|
||||
for (unsigned int i = 0; i < num_elements; i++)
|
||||
{
|
||||
if (elements[i] > sw_depth)
|
||||
break;
|
||||
char *const s = sr_samplecount_string(elements[i]);
|
||||
if (!stream_mode && (elements[i] > hw_depth))
|
||||
_sample_count.addItem(QString(s)+RLEString,
|
||||
qVariantFromValue(elements[i]));
|
||||
else
|
||||
_sample_count.addItem(QString(s),
|
||||
qVariantFromValue(elements[i]));
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
_sample_count.show();
|
||||
g_variant_unref(gvar_list);
|
||||
} else {
|
||||
sw_depth = AnalogMaxSWDepth;
|
||||
}
|
||||
_sample_count.setMinimumWidth(_sample_count.sizeHint().width()+15);
|
||||
_sample_count.view()->setMinimumWidth(_sample_count.sizeHint().width()+30);
|
||||
|
||||
if (0 != _sample_count.count())
|
||||
pre_duration = _sample_count.itemData(
|
||||
_sample_count.currentIndex()).value<double>();
|
||||
_sample_count.clear();
|
||||
const uint64_t samplerate = _sample_rate.itemData(
|
||||
_sample_rate.currentIndex()).value<uint64_t>();
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
duration = SR_SEC(10);
|
||||
else if (stream_mode)
|
||||
duration = sw_depth / (samplerate * (1.0 / SR_SEC(1)));
|
||||
else
|
||||
duration = hw_depth / (samplerate * (1.0 / SR_SEC(1)));
|
||||
|
||||
bool not_last = true;
|
||||
do {
|
||||
char *const s = sr_time_string(duration);
|
||||
_sample_count.addItem(QString(s) + ((dev_inst->dev_inst()->mode == DSO) ? DIVString : ""),
|
||||
qVariantFromValue(duration));
|
||||
g_free(s);
|
||||
|
||||
double unit;
|
||||
if (duration >= SR_DAY(1))
|
||||
unit = SR_DAY(1);
|
||||
else if (duration >= SR_HOUR(1))
|
||||
unit = SR_HOUR(1);
|
||||
else if (duration >= SR_MIN(1))
|
||||
unit = SR_MIN(1);
|
||||
else
|
||||
unit = 1;
|
||||
const double log10_duration = pow(10,
|
||||
floor(log10(duration / unit)));
|
||||
if (duration > 5 * log10_duration * unit)
|
||||
duration = 5 * log10_duration * unit;
|
||||
else if (duration > 2 * log10_duration * unit)
|
||||
duration = 2 * log10_duration * unit;
|
||||
else if (duration > log10_duration * unit)
|
||||
duration = log10_duration * unit;
|
||||
else
|
||||
duration = log10_duration > 1 ? duration * 0.5 :
|
||||
(unit == SR_DAY(1) ? SR_HOUR(20) :
|
||||
unit == SR_HOUR(1) ? SR_MIN(50) :
|
||||
unit == SR_MIN(1) ? SR_SEC(50) : duration * 0.5);
|
||||
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
not_last = duration >= SR_NS(10);
|
||||
else
|
||||
not_last = (duration / SR_SEC(1) * samplerate >= SR_KB(1));
|
||||
} while(not_last);
|
||||
|
||||
_updating_sample_count = true;
|
||||
if (pre_duration > _sample_count.itemData(0).value<double>())
|
||||
_sample_count.setCurrentIndex(0);
|
||||
else if (pre_duration < _sample_count.itemData(_sample_count.count()-1).value<double>())
|
||||
_sample_count.setCurrentIndex(_sample_count.count()-1);
|
||||
else {
|
||||
for (int i = 0; i < _sample_count.count(); i++)
|
||||
if (pre_duration >= _sample_count.itemData(
|
||||
i).value<double>()) {
|
||||
_sample_count.setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
sample_count_changed();
|
||||
}
|
||||
_updating_sample_count = false;
|
||||
g_variant_unref(gvar_dict);
|
||||
|
||||
update_sample_count_selector_value();
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
update_sample_count_selector_value();
|
||||
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
}
|
||||
@@ -653,58 +540,118 @@ void SamplingBar::update_sample_count_selector_value()
|
||||
if (_updating_sample_count)
|
||||
return;
|
||||
|
||||
const uint64_t samplecount = get_selected_device()->get_sample_limit();
|
||||
|
||||
GVariant* gvar;
|
||||
double hori_res;
|
||||
gvar = get_selected_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
||||
if (gvar != NULL) {
|
||||
hori_res = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return;
|
||||
}
|
||||
assert(!_updating_sample_count);
|
||||
_updating_sample_count = true;
|
||||
|
||||
for (int i = 0; i < _sample_count.count(); i++)
|
||||
if (samplecount == _sample_count.itemData(
|
||||
i).value<uint64_t>())
|
||||
_sample_count.setCurrentIndex(i);
|
||||
|
||||
if (samplecount != _sample_count.itemData(_sample_count.currentIndex()).value<uint64_t>()) {
|
||||
sample_count_changed();
|
||||
if (hori_res != _sample_count.itemData(
|
||||
_sample_count.currentIndex()).value<double>()) {
|
||||
for (int i = _sample_count.count() - 1; i >= 0; i--) {
|
||||
if (hori_res == _sample_count.itemData(
|
||||
i).value<double>()) {
|
||||
_sample_count.setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_updating_sample_count = false;
|
||||
}
|
||||
|
||||
void SamplingBar::commit_sample_count()
|
||||
void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
uint64_t sample_count = 0;
|
||||
uint64_t last_sample_count = 0;
|
||||
(void)index;
|
||||
|
||||
if (_updating_sample_count)
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
commit_hori_res();
|
||||
else
|
||||
sample_count_changed();
|
||||
}
|
||||
|
||||
void SamplingBar::hori_knob(int dir)
|
||||
{
|
||||
if (0 == dir) {
|
||||
commit_hori_res();
|
||||
} else if ((dir > 0) && (_sample_count.currentIndex() > 0)) {
|
||||
_sample_count.setCurrentIndex(_sample_count.currentIndex() - 1);
|
||||
commit_hori_res();
|
||||
} else if ((dir < 0) && (_sample_count.currentIndex() < _sample_count.count() - 1)) {
|
||||
_sample_count.setCurrentIndex(_sample_count.currentIndex() + 1);
|
||||
commit_hori_res();
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::commit_hori_res()
|
||||
{
|
||||
const double hori_res = _sample_count.itemData(
|
||||
_sample_count.currentIndex()).value<double>();
|
||||
|
||||
if (_session.get_capture_state() == SigSession::Running)
|
||||
_session.refresh(RefreshShort);
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
const uint64_t sample_limit = dev_inst->get_sample_limit();
|
||||
GVariant* gvar;
|
||||
uint64_t max_sample_rate;
|
||||
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLERATE);
|
||||
if (gvar != NULL) {
|
||||
max_sample_rate = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.";
|
||||
return;
|
||||
|
||||
assert(!_updating_sample_count);
|
||||
_updating_sample_count = true;
|
||||
|
||||
|
||||
const int index = _sample_count.currentIndex();
|
||||
if (index >= 0)
|
||||
sample_count = _sample_count.itemData(
|
||||
index).value<uint64_t>();
|
||||
|
||||
if (sample_count == 0)
|
||||
return;
|
||||
|
||||
// Get last samplecount
|
||||
last_sample_count = get_selected_device()->get_sample_limit();
|
||||
|
||||
if (last_sample_count != sample_count) {
|
||||
// Set the samplecount
|
||||
get_selected_device()->set_config(NULL, NULL,
|
||||
SR_CONF_LIMIT_SAMPLES,
|
||||
g_variant_new_uint64(sample_count));
|
||||
}
|
||||
|
||||
bool rle_mode = _sample_count.currentText().contains(RLEString);
|
||||
get_selected_device()->set_config(NULL, NULL,
|
||||
SR_CONF_RLE,
|
||||
g_variant_new_boolean(rle_mode));
|
||||
const uint64_t sample_rate = min((uint64_t)(sample_limit * SR_SEC(1) /
|
||||
(hori_res * DS_CONF_DSO_HDIVS)),
|
||||
(uint64_t)(max_sample_rate /
|
||||
(_session.get_ch_num(DSO) ? _session.get_ch_num(DSO) : 1)));
|
||||
set_sample_rate(sample_rate);
|
||||
if (_session.get_capture_state() != SigSession::Stopped)
|
||||
_session.set_cur_samplerate(dev_inst->get_sample_rate());
|
||||
|
||||
_updating_sample_count = false;
|
||||
dev_inst->set_config(NULL, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(hori_res));
|
||||
|
||||
hori_res_changed(hori_res);
|
||||
}
|
||||
|
||||
void SamplingBar::commit_settings()
|
||||
{
|
||||
const double sample_duration = _sample_count.itemData(
|
||||
_sample_count.currentIndex()).value<double>();
|
||||
const uint64_t sample_rate = _sample_rate.itemData(
|
||||
_sample_rate.currentIndex()).value<uint64_t>();
|
||||
const uint64_t sample_count = ceil(sample_duration / SR_SEC(1) *
|
||||
sample_rate);
|
||||
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (dev_inst) {
|
||||
if (sample_rate != dev_inst->get_sample_rate())
|
||||
dev_inst->set_config(NULL, NULL,
|
||||
SR_CONF_SAMPLERATE,
|
||||
g_variant_new_uint64(sample_rate));
|
||||
if (dev_inst->dev_inst()->mode != DSO) {
|
||||
if (sample_count != dev_inst->get_sample_limit())
|
||||
dev_inst->set_config(NULL, NULL,
|
||||
SR_CONF_LIMIT_SAMPLES,
|
||||
g_variant_new_uint64(sample_count));
|
||||
|
||||
bool rle_mode = _sample_count.currentText().contains(RLEString);
|
||||
dev_inst->set_config(NULL, NULL,
|
||||
SR_CONF_RLE,
|
||||
g_variant_new_boolean(rle_mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::on_run_stop()
|
||||
@@ -726,8 +673,7 @@ void SamplingBar::on_run_stop()
|
||||
} else {
|
||||
enable_run_stop(false);
|
||||
enable_instant(false);
|
||||
commit_sample_rate();
|
||||
commit_sample_count();
|
||||
commit_settings();
|
||||
_instant = false;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
@@ -779,8 +725,7 @@ void SamplingBar::on_instant_stop()
|
||||
} else {
|
||||
enable_run_stop(false);
|
||||
enable_instant(false);
|
||||
commit_sample_rate();
|
||||
commit_sample_count();
|
||||
commit_settings();
|
||||
_instant = true;
|
||||
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
|
||||
if (!dev_inst)
|
||||
@@ -845,7 +790,10 @@ void SamplingBar::enable_toggle(bool enable)
|
||||
}
|
||||
if (!test) {
|
||||
_sample_count.setDisabled(!enable);
|
||||
_sample_rate.setDisabled(!enable);
|
||||
if (dev_inst->dev_inst()->mode == DSO)
|
||||
_sample_rate.setDisabled(true);
|
||||
else
|
||||
_sample_rate.setDisabled(!enable);
|
||||
} else {
|
||||
_sample_count.setDisabled(true);
|
||||
_sample_rate.setDisabled(true);
|
||||
@@ -900,7 +848,7 @@ void SamplingBar::reload()
|
||||
_mode_action->setVisible(false);
|
||||
_run_stop_action->setVisible(true);
|
||||
_instant_action->setVisible(true);
|
||||
enable_toggle(false);
|
||||
enable_toggle(true);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -60,10 +60,13 @@ class SamplingBar : public QToolBar
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
static const uint64_t RecordLengths[19];
|
||||
static const uint64_t DefaultRecordLength;
|
||||
static const int ComboBoxMaxWidth = 200;
|
||||
static const int RefreshShort = 200;
|
||||
static const uint64_t LogicMaxSWDepth64 = SR_GB(16);
|
||||
static const uint64_t LogicMaxSWDepth32 = SR_GB(8);
|
||||
static const uint64_t AnalogMaxSWDepth = SR_Mn(100);
|
||||
static const QString RLEString;
|
||||
static const QString DIVString;
|
||||
|
||||
public:
|
||||
SamplingBar(SigSession &session, QWidget *parent);
|
||||
@@ -73,11 +76,7 @@ public:
|
||||
|
||||
boost::shared_ptr<pv::device::DevInst> get_selected_device() const;
|
||||
|
||||
uint64_t get_record_length() const;
|
||||
void set_record_length(uint64_t length);
|
||||
void update_record_length();
|
||||
|
||||
void update_sample_rate();
|
||||
void update_sample_rate_selector();
|
||||
|
||||
void set_sampling(bool sampling);
|
||||
bool get_sampling() const;
|
||||
@@ -89,9 +88,11 @@ public:
|
||||
|
||||
void enable_instant(bool enable);
|
||||
|
||||
void hori_knob(int dir);
|
||||
void commit_hori_res();
|
||||
|
||||
public slots:
|
||||
void set_sample_rate(uint64_t sample_rate);
|
||||
void set_sample_limit(uint64_t sample_limit);
|
||||
|
||||
signals:
|
||||
void run_stop();
|
||||
@@ -101,14 +102,13 @@ signals:
|
||||
void sample_count_changed();
|
||||
void show_calibration();
|
||||
void hide_calibration();
|
||||
void hori_res_changed(double hori_res);
|
||||
|
||||
private:
|
||||
void update_sample_rate_selector();
|
||||
void update_sample_rate_selector_value();
|
||||
void update_sample_count_selector();
|
||||
void update_sample_count_selector_value();
|
||||
void commit_sample_rate();
|
||||
void commit_sample_count();
|
||||
void commit_settings();
|
||||
void setting_adj();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -47,35 +47,38 @@ dslDial::~dslDial()
|
||||
{
|
||||
}
|
||||
|
||||
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
|
||||
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, const QPoint pt)
|
||||
{
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setPen(dialColor);
|
||||
p.setBrush(dialColor);
|
||||
|
||||
int dialStartAngle = 225 * 16;
|
||||
int dialSpanAngle = -270 * 16;
|
||||
int dialMarginAngle = 15 * 16;
|
||||
int dialStartAngle = 75 * 16;
|
||||
int dialSpanAngle = -150 * 16;
|
||||
|
||||
// draw dial arc
|
||||
p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
|
||||
p.drawArc(dialRect, dialStartAngle + dialMarginAngle,
|
||||
dialSpanAngle - dialMarginAngle * 2);
|
||||
// draw ticks
|
||||
p.save();
|
||||
p.translate(dialRect.center());
|
||||
p.rotate(45);
|
||||
p.rotate(270 - dialStartAngle/16);
|
||||
// draw pointer
|
||||
p.rotate(-dialSpanAngle/16.0/(_div-1)*_sel);
|
||||
p.drawEllipse(-3, -3, 6, 6);
|
||||
p.drawLine(3, 0, 0, dialRect.width()/2-3);
|
||||
p.drawLine(-3, 0, 0, dialRect.width()/2-3);
|
||||
p.rotate(+dialSpanAngle/16.0/(_div-1)*_sel);
|
||||
for (uint64_t i = 0; i < _div; i++) {
|
||||
// draw major ticks
|
||||
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
|
||||
// draw minor ticks
|
||||
for (uint64_t j = 0; (j < 5) && (i < _div - 1); j++) {
|
||||
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
|
||||
p.rotate(54.0/(_div-1));
|
||||
p.rotate(-dialSpanAngle/16/5.0/(_div-1));
|
||||
}
|
||||
}
|
||||
// draw pointer
|
||||
p.rotate(90+270.0/(_div-1)*_sel);
|
||||
p.drawEllipse(-3, -3, 6, 6);
|
||||
p.drawLine(3, 0, 0, dialRect.width()/2-3);
|
||||
p.drawLine(-3, 0, 0, dialRect.width()/2-3);
|
||||
p.restore();
|
||||
// draw value
|
||||
uint64_t displayValue = _value[_sel]*_factor;
|
||||
@@ -84,23 +87,27 @@ void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover,
|
||||
displayValue = displayValue / _step;
|
||||
displayIndex++;
|
||||
}
|
||||
QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
|
||||
QString pText = QString::number(displayValue) + _unit[displayIndex] + tr(" / div");
|
||||
QFontMetrics fm(p.font());
|
||||
const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height());
|
||||
const QRectF valueRect = QRectF(dialRect.left(), dialRect.top()-fm.height()-10, dialRect.width(), fm.height());
|
||||
p.drawText(valueRect, Qt::AlignCenter, pText);
|
||||
|
||||
// draw +/-
|
||||
if (hover) {
|
||||
const int arcInc = 15;
|
||||
const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc, dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
|
||||
const double arcSpan = hoverRect.width()/(2*sqrt(2));
|
||||
p.drawArc(hoverRect, 135 * 16, -90 * 16);
|
||||
if (dialRect.contains(pt) && pt.x() > dialRect.center().x()) {
|
||||
const int arcInc = 12;
|
||||
const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc,
|
||||
dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
|
||||
p.drawArc(hoverRect, dialStartAngle + dialSpanAngle/4, dialSpanAngle/2);
|
||||
p.save();
|
||||
p.translate(hoverRect.center());
|
||||
const bool inc = pt.y() > dialRect.center().y();
|
||||
if (inc)
|
||||
p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
|
||||
hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
|
||||
p.rotate(270-(dialStartAngle/16 + dialSpanAngle/16/4 + dialSpanAngle/16/2));
|
||||
else
|
||||
p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
|
||||
hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
|
||||
p.rotate(270-(dialStartAngle/16 + dialSpanAngle/16/4));
|
||||
p.drawLine(0, hoverRect.width()/2,
|
||||
inc ? 10 : -10, hoverRect.width()/2 + 4);
|
||||
p.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
class dslDial
|
||||
class dslDial : public QObject
|
||||
{
|
||||
//Q_OBJECT
|
||||
|
||||
public:
|
||||
dslDial(const uint64_t div, const uint64_t step,
|
||||
const QVector<uint64_t> value, const QVector<QString> unit);
|
||||
@@ -41,7 +43,8 @@ public:
|
||||
* @param p the QPainter to paint into.
|
||||
* @param dialRect the rectangle to draw the dial at.
|
||||
**/
|
||||
void paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc);
|
||||
void paint(QPainter &p, QRectF dialRect, QColor dialColor,
|
||||
const QPoint pt);
|
||||
|
||||
// set/get current select
|
||||
void set_sel(uint64_t sel);
|
||||
|
||||
@@ -55,44 +55,6 @@ const QString DsoSignal::vDialUnit[DsoSignal::vDialUnitCount] = {
|
||||
"v",
|
||||
};
|
||||
|
||||
const uint64_t DsoSignal::hDialValue[DsoSignal::hDialValueCount] = {
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
1000,
|
||||
2000,
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
50000,
|
||||
100000,
|
||||
200000,
|
||||
500000,
|
||||
1000000,
|
||||
2000000,
|
||||
5000000,
|
||||
10000000,
|
||||
20000000,
|
||||
50000000,
|
||||
100000000,
|
||||
200000000,
|
||||
500000000,
|
||||
1000000000,
|
||||
2000000000,
|
||||
5000000000,
|
||||
10000000000,
|
||||
};
|
||||
|
||||
const QString DsoSignal::hDialUnit[DsoSignal::hDialUnitCount] = {
|
||||
"ns",
|
||||
"us",
|
||||
"ms",
|
||||
"s",
|
||||
};
|
||||
|
||||
const QColor DsoSignal::SignalColours[4] = {
|
||||
QColor(238, 178, 17, 255), // dsYellow
|
||||
QColor(0, 153, 37, 255), // dsGreen
|
||||
@@ -110,7 +72,6 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
_data(data),
|
||||
_scale(0),
|
||||
_vDialActive(false),
|
||||
_hDialActive(false),
|
||||
_autoV(false),
|
||||
_autoH(false),
|
||||
_hover_en(false),
|
||||
@@ -122,20 +83,12 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
{
|
||||
QVector<uint64_t> vValue;
|
||||
QVector<QString> vUnit;
|
||||
QVector<uint64_t> hValue;
|
||||
QVector<QString> hUnit;
|
||||
for(uint64_t i = 0; i < vDialValueCount; i++)
|
||||
vValue.append(vDialValue[i]);
|
||||
for(uint64_t i = 0; i < vDialUnitCount; i++)
|
||||
vUnit.append(vDialUnit[i]);
|
||||
|
||||
for(uint64_t i = 0; i < hDialValueCount; i++)
|
||||
hValue.append(hDialValue[i]);
|
||||
for(uint64_t i = 0; i < hDialUnitCount; i++)
|
||||
hUnit.append(hDialUnit[i]);
|
||||
|
||||
_vDial = new dslDial(vDialValueCount, vDialValueStep, vValue, vUnit);
|
||||
_hDial = new dslDial(hDialValueCount, hDialValueStep, hValue, hUnit);
|
||||
|
||||
_colour = SignalColours[probe->index % countof(SignalColours)];
|
||||
|
||||
@@ -179,6 +132,11 @@ float DsoSignal::get_scale()
|
||||
return _scale;
|
||||
}
|
||||
|
||||
int DsoSignal::get_name_width() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DsoSignal::set_enable(bool enable)
|
||||
{
|
||||
if (_dev_inst->name() == "DSLogic" &&
|
||||
@@ -211,7 +169,7 @@ void DsoSignal::set_enable(bool enable)
|
||||
g_variant_new_boolean(enable));
|
||||
|
||||
if (running) {
|
||||
update_capture(_view->session().get_instant());
|
||||
_view->update_hori_res();
|
||||
_view->session().repeat_resume();
|
||||
}
|
||||
|
||||
@@ -274,152 +232,6 @@ bool DsoSignal::go_vDialNext()
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::get_hDialActive() const
|
||||
{
|
||||
return _hDialActive;
|
||||
}
|
||||
|
||||
void DsoSignal::set_hDialActive(bool active)
|
||||
{
|
||||
_hDialActive = active;
|
||||
}
|
||||
|
||||
bool DsoSignal::go_hDialPre(bool setted)
|
||||
{
|
||||
int ch_num = _view->session().get_ch_num(SR_CHANNEL_DSO);
|
||||
if (ch_num != 0 && !_hDial->isMin()) {
|
||||
uint64_t sample_rate = _view->session().get_device()->get_sample_rate();
|
||||
const uint64_t min_div = std::pow(10.0, 9.0) / sample_rate;
|
||||
if (_view->session().get_capture_state() != SigSession::Running &&
|
||||
!_data->get_snapshots().front()->empty()) {
|
||||
if (_hDial->get_value() > min_div)
|
||||
_hDial->set_sel(_hDial->get_sel() - 1);
|
||||
} else if ((_view->session().get_capture_state() == SigSession::Running ||
|
||||
_data->get_snapshots().front()->empty()) &&
|
||||
!_view->session().get_instant()) {
|
||||
_view->session().refresh(RefreshShort);
|
||||
_hDial->set_sel(_hDial->get_sel() - 1);
|
||||
|
||||
if (!setted) {
|
||||
uint64_t sample_limit = _view->session().get_device()->get_sample_limit();
|
||||
GVariant* gvar;
|
||||
uint64_t max_sample_rate;
|
||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLERATE);
|
||||
if (gvar != NULL) {
|
||||
max_sample_rate = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
sample_rate = min((uint64_t)(sample_limit * std::pow(10.0, 9.0) / (_hDial->get_value() * DS_CONF_DSO_HDIVS)),
|
||||
(uint64_t)(max_sample_rate / (ch_num ? ch_num : 1)));
|
||||
_view->set_sample_rate(sample_rate, true);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (!setted) {
|
||||
const double scale = _hDial->get_value() * std::pow(10.0, -9.0) * DS_CONF_DSO_HDIVS / get_view_rect().width();
|
||||
_view->set_scale_offset(scale, _view->offset());
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_autoH = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::update_capture(bool instant)
|
||||
{
|
||||
int ch_num = _view->session().get_ch_num(SR_CHANNEL_DSO);
|
||||
if (ch_num == 0)
|
||||
return false;
|
||||
|
||||
_view->session().refresh(RefreshShort);
|
||||
uint64_t max_sample_rate;
|
||||
uint64_t max_sample_limit;
|
||||
GVariant *gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLERATE);
|
||||
if (gvar != NULL) {
|
||||
max_sample_rate = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.";
|
||||
return false;
|
||||
}
|
||||
if (instant)
|
||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_HW_DEPTH);
|
||||
else
|
||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLELIMITS);
|
||||
if (gvar != NULL) {
|
||||
max_sample_limit = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLELIMITS failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t sample_limit = (uint64_t)(max_sample_limit / (ch_num ? ch_num : 1));
|
||||
uint64_t sample_rate = min((uint64_t)(sample_limit * std::pow(10.0, 9.0) / (_hDial->get_value() * DS_CONF_DSO_HDIVS)),
|
||||
(uint64_t)(max_sample_rate / (ch_num ? ch_num : 1)));
|
||||
|
||||
_view->set_sample_limit(sample_limit, true);
|
||||
_view->set_sample_rate(sample_rate, true);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DsoSignal::go_hDialNext(bool setted)
|
||||
{
|
||||
int ch_num = _view->session().get_ch_num(SR_CHANNEL_DSO);
|
||||
if (ch_num != 0 && !_hDial->isMax()) {
|
||||
if (_view->session().get_capture_state() != SigSession::Running &&
|
||||
!_data->get_snapshots().front()->empty()) {
|
||||
_hDial->set_sel(_hDial->get_sel() + 1);
|
||||
} else if ((_view->session().get_capture_state() == SigSession::Running ||
|
||||
_data->get_snapshots().front()->empty()) &&
|
||||
!_view->session().get_instant()) {
|
||||
_view->session().refresh(RefreshShort);
|
||||
_hDial->set_sel(_hDial->get_sel() + 1);
|
||||
|
||||
if (!setted) {
|
||||
uint64_t sample_limit = _view->session().get_device()->get_sample_limit();
|
||||
|
||||
GVariant* gvar;
|
||||
uint64_t max_sample_rate;
|
||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLERATE);
|
||||
if (gvar != NULL) {
|
||||
max_sample_rate = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t sample_rate = min((uint64_t)(sample_limit * std::pow(10.0, 9.0) / (_hDial->get_value() * DS_CONF_DSO_HDIVS)),
|
||||
(uint64_t)(max_sample_rate / (ch_num ? ch_num : 1)));
|
||||
_view->set_sample_rate(sample_rate, true);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (!setted) {
|
||||
const double scale = _hDial->get_value() * std::pow(10.0, -9.0) * DS_CONF_DSO_HDIVS / get_view_rect().width();
|
||||
_view->set_scale_offset(scale, _view->offset());
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_autoH = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::load_settings()
|
||||
{
|
||||
GVariant* gvar;
|
||||
@@ -447,25 +259,6 @@ bool DsoSignal::load_settings()
|
||||
return false;
|
||||
}
|
||||
|
||||
// -- hdiv
|
||||
uint64_t hdiv;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TIMEBASE);
|
||||
if (gvar != NULL) {
|
||||
hdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_hDial->set_value(hdiv);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
if (_view) {
|
||||
const double scale = _hDial->get_value() * std::pow(10.0, -9.0) * DS_CONF_DSO_HDIVS / get_view_rect().width();
|
||||
_view->set_scale_offset(scale, _view->offset());
|
||||
}
|
||||
|
||||
// -- vdiv
|
||||
uint64_t vdiv;
|
||||
uint64_t vfactor;
|
||||
@@ -544,10 +337,6 @@ int DsoSignal::commit_settings()
|
||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
||||
g_variant_new_boolean(enabled()));
|
||||
|
||||
// -- hdiv
|
||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_TIMEBASE,
|
||||
g_variant_new_uint64(_hDial->get_value()));
|
||||
|
||||
// -- vdiv
|
||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
@@ -575,21 +364,11 @@ uint64_t DsoSignal::get_vDialValue() const
|
||||
return _vDial->get_value();
|
||||
}
|
||||
|
||||
uint64_t DsoSignal::get_hDialValue() const
|
||||
{
|
||||
return _hDial->get_value();
|
||||
}
|
||||
|
||||
uint16_t DsoSignal::get_vDialSel() const
|
||||
{
|
||||
return _vDial->get_sel();
|
||||
}
|
||||
|
||||
uint16_t DsoSignal::get_hDialSel() const
|
||||
{
|
||||
return _hDial->get_sel();
|
||||
}
|
||||
|
||||
uint8_t DsoSignal::get_acCoupling() const
|
||||
{
|
||||
return _acCoupling;
|
||||
@@ -895,7 +674,8 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
const uint16_t number_channels = snapshot->get_channel_num();
|
||||
const double pixels_offset = offset;
|
||||
//const double samplerate = _data->samplerate();
|
||||
const double samplerate = _dev_inst->get_sample_rate();
|
||||
//const double samplerate = _dev_inst->get_sample_rate();
|
||||
const double samplerate = _view->session().cur_samplerate();
|
||||
const int64_t last_sample = max((int64_t)(snapshot->get_sample_count() - 1), (int64_t)0);
|
||||
const double samples_per_pixel = samplerate * scale;
|
||||
const double start = offset * samples_per_pixel;
|
||||
@@ -1113,18 +893,14 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
int y = get_y();
|
||||
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
|
||||
const QRectF vInc_rect = get_rect(DSO_VINC, y, right);
|
||||
const QRectF hDial_rect = get_rect(DSO_HDIAL, y, right);
|
||||
const QRectF hInc_rect = get_rect(DSO_HINC, y, right);
|
||||
|
||||
const QRectF x1_rect = get_rect(DSO_X1, y, right);
|
||||
const QRectF x10_rect = get_rect(DSO_X10, y, right);
|
||||
const QRectF x100_rect = get_rect(DSO_X100, y, right);
|
||||
const QRectF acdc_rect = get_rect(DSO_ACDC, y, right);
|
||||
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
|
||||
const QRectF auto_rect = get_rect(DSO_AUTO, y, right);
|
||||
|
||||
_vDial->paint(p, vDial_rect, _colour, vDial_rect.contains(pt), vInc_rect.contains(pt));
|
||||
_hDial->paint(p, hDial_rect, _colour, hDial_rect.contains(pt), hInc_rect.contains(pt));
|
||||
_vDial->paint(p, vDial_rect, _colour, pt);
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(chEn_rect.contains(pt) ? _colour.darker() : _colour);
|
||||
@@ -1139,6 +915,12 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, (_acCoupling == SR_GND_COUPLING) ? tr("GND") :
|
||||
(_acCoupling == SR_DC_COUPLING) ? tr("DC") : tr("AC"));
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(enabled() ? (auto_rect.contains(pt) ? _colour.darker() : _colour) : dsDisable);
|
||||
p.drawRect(auto_rect);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(auto_rect, Qt::AlignCenter | Qt::AlignVCenter, tr("AUTO"));
|
||||
|
||||
// paint the probe factor selector
|
||||
GVariant* gvar;
|
||||
uint64_t factor;
|
||||
@@ -1179,12 +961,7 @@ bool DsoSignal::mouse_double_click(int right, const QPoint pt)
|
||||
bool DsoSignal::mouse_press(int right, const QPoint pt)
|
||||
{
|
||||
int y = get_y();
|
||||
bool setted = false;
|
||||
const vector< boost::shared_ptr<Trace> > traces(_view->get_traces(ALL_VIEW));
|
||||
const QRectF vDec_rect = get_rect(DSO_VDEC, y, right);
|
||||
const QRectF vInc_rect = get_rect(DSO_VINC, y, right);
|
||||
const QRectF hDec_rect = get_rect(DSO_HDEC, y, right);
|
||||
const QRectF hInc_rect = get_rect(DSO_HINC, y, right);
|
||||
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
|
||||
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
|
||||
const QRectF acdc_rect = get_rect(DSO_ACDC, y, right);
|
||||
const QRectF x1_rect = get_rect(DSO_X1, y, right);
|
||||
@@ -1197,26 +974,11 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
|
||||
set_enable(!enabled());
|
||||
return true;
|
||||
} else if (enabled()) {
|
||||
if (vDec_rect.contains(pt)) {
|
||||
go_vDialPre();
|
||||
} else if (vInc_rect.contains(pt)) {
|
||||
go_vDialNext();
|
||||
} else if (hDec_rect.contains(pt)) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->go_hDialPre(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
} else if (hInc_rect.contains(pt)) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->go_hDialNext(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
if (vDial_rect.contains(pt) && pt.x() > vDial_rect.center().x()) {
|
||||
if (pt.y() > vDial_rect.center().y())
|
||||
go_vDialNext();
|
||||
else
|
||||
go_vDialPre();
|
||||
} else if (_dev_inst->name() != "virtual-session" &&
|
||||
acdc_rect.contains(pt)) {
|
||||
if (_dev_inst->name() == "DSLogic")
|
||||
@@ -1240,31 +1002,14 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
|
||||
bool DsoSignal::mouse_wheel(int right, const QPoint pt, const int shift)
|
||||
{
|
||||
int y = get_y();
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view->get_traces(ALL_VIEW));
|
||||
bool setted = false;
|
||||
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
|
||||
const QRectF hDial_rect = get_rect(DSO_HDIAL, y, right);
|
||||
|
||||
if (vDial_rect.contains(pt)) {
|
||||
if (shift > 0.5)
|
||||
go_vDialNext();
|
||||
else if (shift < -0.5)
|
||||
go_vDialPre();
|
||||
else if (shift < -0.5)
|
||||
go_vDialNext();
|
||||
return true;
|
||||
} else if (hDial_rect.contains(pt)) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
if (shift > 0.5) {
|
||||
dsoSig->go_hDialNext(setted);
|
||||
setted = true;
|
||||
} else if (shift < -0.5) {
|
||||
dsoSig->go_hDialPre(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1274,63 +1019,43 @@ bool DsoSignal::mouse_wheel(int right, const QPoint pt, const int shift)
|
||||
|
||||
QRectF DsoSignal::get_rect(DsoSetRegions type, int y, int right)
|
||||
{
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
(void)right;
|
||||
|
||||
if (type == DSO_VDIAL)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum,
|
||||
get_leftWidth() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum + SquareWidth * 3,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_VDEC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum,
|
||||
SquareWidth * (SquareNum-1) / 2, SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_VINC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin + SquareWidth * (SquareNum-1) / 2,
|
||||
y - SquareWidth * SquareNum,
|
||||
SquareWidth * (SquareNum-1) / 2, SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_HDIAL)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y + SquareWidth * 1.5,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_HDEC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y + SquareWidth * 1.5,
|
||||
SquareWidth * (SquareNum-1) / 2, SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_HINC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin + SquareWidth * (SquareNum-1) / 2,
|
||||
y + SquareWidth * 1.5,
|
||||
SquareWidth * (SquareNum-1) / 2, SquareWidth * (SquareNum-1));
|
||||
else if (type == DSO_X1)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.85,
|
||||
get_leftWidth() + SquareWidth*0.5,
|
||||
y - SquareWidth * 2 - SquareWidth * (SquareNum-2) * 1 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (type == DSO_X10)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.55,
|
||||
get_leftWidth() + SquareWidth*0.5,
|
||||
y - SquareWidth * 2 - SquareWidth * (SquareNum-2) * 0.5 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (type == DSO_X100)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.25,
|
||||
get_leftWidth() + SquareWidth*0.5,
|
||||
y - SquareWidth * 2 - SquareWidth * (SquareNum-2) * 0 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (type == DSO_CHEN)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
2,
|
||||
y - SquareWidth / 2 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (type == DSO_ACDC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*2.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
2+SquareWidth*1.75 + Margin,
|
||||
y - SquareWidth / 2 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (type == DSO_AUTO)
|
||||
return QRectF(
|
||||
2+SquareWidth*3.5 + Margin*2,
|
||||
y - SquareWidth / 2 + SquareWidth * 3,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
@@ -1445,33 +1170,6 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
go_vDialPre();
|
||||
}
|
||||
}
|
||||
|
||||
bool setted = false;
|
||||
if (_autoH) {
|
||||
const vector< boost::shared_ptr<Trace> > traces(_view->get_traces(ALL_VIEW));
|
||||
const double upPeriod = get_hDialValue() * DS_CONF_DSO_HDIVS * 0.8;
|
||||
const double dnPeriod = get_hDialValue() * DS_CONF_DSO_HDIVS * 0.2;
|
||||
if (_period > upPeriod) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->go_hDialNext(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
} else if (_period > dnPeriod) {
|
||||
_autoH = false;
|
||||
} else {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->go_hDialPre(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//_view->update();
|
||||
}
|
||||
|
||||
void DsoSignal::auto_set()
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace view {
|
||||
|
||||
class DsoSignal : public Signal
|
||||
{
|
||||
//Q_OBJECT
|
||||
|
||||
private:
|
||||
static const QColor SignalColours[4];
|
||||
static const float EnvelopeThreshold;
|
||||
@@ -48,15 +50,9 @@ private:
|
||||
static const uint64_t vDialValueCount = 8;
|
||||
static const uint64_t vDialValueStep = 1000;
|
||||
static const uint64_t vDialUnitCount = 2;
|
||||
static const uint64_t hDialValueCount = 28;
|
||||
static const uint64_t hDialValueStep = 1000;
|
||||
static const uint64_t hDialUnitCount = 4;
|
||||
static const uint64_t vDialValue[vDialValueCount];
|
||||
static const QString vDialUnit[vDialUnitCount];
|
||||
|
||||
static const uint64_t hDialValue[hDialValueCount];
|
||||
static const QString hDialUnit[hDialUnitCount];
|
||||
|
||||
static const int UpMargin = 30;
|
||||
static const int DownMargin = 0;
|
||||
static const int RightMargin = 30;
|
||||
@@ -70,13 +66,9 @@ public:
|
||||
enum DsoSetRegions {
|
||||
DSO_NONE = -1,
|
||||
DSO_VDIAL,
|
||||
DSO_HDIAL,
|
||||
DSO_VDEC,
|
||||
DSO_VINC,
|
||||
DSO_HDEC,
|
||||
DSO_HINC,
|
||||
DSO_CHEN,
|
||||
DSO_ACDC,
|
||||
DSO_AUTO,
|
||||
DSO_X1,
|
||||
DSO_X10,
|
||||
DSO_X100,
|
||||
@@ -103,23 +95,19 @@ public:
|
||||
void set_scale(int height);
|
||||
float get_scale();
|
||||
|
||||
int get_name_width() const;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void set_enable(bool enable);
|
||||
bool get_vDialActive() const;
|
||||
void set_vDialActive(bool active);
|
||||
bool get_hDialActive() const;
|
||||
void set_hDialActive(bool active);
|
||||
bool go_vDialPre();
|
||||
bool go_vDialNext();
|
||||
bool go_hDialPre(bool setted);
|
||||
bool go_hDialNext(bool setted);
|
||||
bool update_capture(bool instant);
|
||||
uint64_t get_vDialValue() const;
|
||||
uint64_t get_hDialValue() const;
|
||||
uint16_t get_vDialSel() const;
|
||||
uint16_t get_hDialSel() const;
|
||||
uint8_t get_acCoupling() const;
|
||||
void set_acCoupling(uint8_t coupling);
|
||||
void set_trig_vpos(int pos, bool delta_change);
|
||||
@@ -223,9 +211,7 @@ private:
|
||||
float _scale;
|
||||
|
||||
dslDial *_vDial;
|
||||
dslDial *_hDial;
|
||||
bool _vDialActive;
|
||||
bool _hDialActive;
|
||||
uint8_t _acCoupling;
|
||||
uint8_t _bits;
|
||||
|
||||
|
||||
@@ -261,7 +261,8 @@ void Header::wheelEvent(QWheelEvent *event)
|
||||
|
||||
void Header::changeName(QMouseEvent *event)
|
||||
{
|
||||
if ((event->button() == Qt::LeftButton)) {
|
||||
if ((event->button() == Qt::LeftButton) &&
|
||||
(_context_trace->get_type() != SR_CHANNEL_DSO)) {
|
||||
header_resize();
|
||||
nameEdit->setText(_context_trace->get_name());
|
||||
nameEdit->selectAll();
|
||||
|
||||
@@ -78,6 +78,7 @@ MathTrace::MathTrace(pv::SigSession &session,
|
||||
_scale(1),
|
||||
_offset(0)
|
||||
{
|
||||
_typeWidth = 0;
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
for(size_t i = 0; i < sigs.size(); i++) {
|
||||
const boost::shared_ptr<view::Signal> s(sigs[i]);
|
||||
|
||||
@@ -120,6 +120,14 @@ QString Trace::get_name() const
|
||||
return _name;
|
||||
}
|
||||
|
||||
int Trace::get_name_width() const
|
||||
{
|
||||
QFont font = QApplication::font();
|
||||
QFontMetrics fm(font);
|
||||
|
||||
return fm.boundingRect(get_name()).width();
|
||||
}
|
||||
|
||||
void Trace::set_name(QString name)
|
||||
{
|
||||
_name = name;
|
||||
@@ -271,10 +279,16 @@ void Trace::paint_label(QPainter &p, int right, const QPoint pt)
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(enabled() ? _colour : dsDisable);
|
||||
p.drawRect(color_rect);
|
||||
if (_type == SR_CHANNEL_DSO) {
|
||||
p.setPen(enabled() ? Qt::white: dsDisable);
|
||||
p.drawText(color_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
|
||||
}
|
||||
|
||||
// Paint the signal name
|
||||
p.setPen(enabled() ? DARK_FORE: dsDisable);
|
||||
p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
|
||||
if (_type != SR_CHANNEL_DSO) {
|
||||
// Paint the signal name
|
||||
p.setPen(enabled() ? DARK_FORE: dsDisable);
|
||||
p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
|
||||
}
|
||||
|
||||
// Paint the trigButton
|
||||
paint_type_options(p, right, pt);
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
* Gets the name of this signal.
|
||||
*/
|
||||
QString get_name() const;
|
||||
virtual int get_name_width() const;
|
||||
|
||||
/**
|
||||
* Sets the name of the signal.
|
||||
|
||||
@@ -231,7 +231,8 @@ void View::capture_init(bool instant)
|
||||
if (_session.get_device()->dev_inst()->mode == ANALOG)
|
||||
set_scale_offset(_maxscale, 0);
|
||||
|
||||
update_sample(instant);
|
||||
_session.get_device()->set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(instant));
|
||||
update_hori_res();
|
||||
status_clear();
|
||||
}
|
||||
|
||||
@@ -251,34 +252,13 @@ void View::set_all_update(bool need_update)
|
||||
viewport->set_need_update(need_update);
|
||||
}
|
||||
|
||||
void View::update_sample(bool instant)
|
||||
void View::update_hori_res()
|
||||
{
|
||||
_session.get_device()->set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(instant));
|
||||
BOOST_FOREACH(const boost::shared_ptr<pv::view::Signal> s, _session.get_signals()) {
|
||||
boost::shared_ptr<pv::view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<pv::view::DsoSignal>(s)) {
|
||||
dsoSig->update_capture(instant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_sampling_bar->hori_knob(0);
|
||||
|
||||
void View::set_sample_rate(uint64_t sample_rate, bool force)
|
||||
{
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force) {
|
||||
_sampling_bar->set_sample_rate(sample_rate);
|
||||
_session.set_cur_samplerate(_session.get_device()->get_sample_rate());
|
||||
}
|
||||
}
|
||||
|
||||
void View::set_sample_limit(uint64_t sample_limit, bool force)
|
||||
{
|
||||
if (_session.get_capture_state() != pv::SigSession::Stopped || force) {
|
||||
_sampling_bar->set_sample_limit(sample_limit);
|
||||
const uint64_t final_limit = _session.get_device()->get_sample_limit();
|
||||
_trig_cursor->set_index(_trig_cursor->index() * 1.0 / _session.cur_samplelimits() * final_limit);
|
||||
_session.set_cur_samplelimits(final_limit);
|
||||
}
|
||||
const uint64_t final_limit = _session.get_device()->get_sample_limit();
|
||||
_trig_cursor->set_index(_trig_cursor->index() * 1.0 / _session.cur_samplelimits() * final_limit);
|
||||
_session.set_cur_samplelimits(final_limit);
|
||||
}
|
||||
|
||||
void View::zoom(double steps, int offset)
|
||||
@@ -291,21 +271,15 @@ void View::zoom(double steps, int offset)
|
||||
//_scale *= std::pow(3.0/2.0, -steps);
|
||||
_scale *= std::pow(2, -steps);
|
||||
_scale = max(min(_scale, _maxscale), _minscale);
|
||||
}else {
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
bool setted = false;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
boost::shared_ptr<DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
|
||||
if(steps > 0.5)
|
||||
dsoSig->go_hDialPre(setted);
|
||||
else if (steps < -0.5)
|
||||
dsoSig->go_hDialNext(setted);
|
||||
else
|
||||
break;
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_session.get_capture_state() == SigSession::Running &&
|
||||
_session.get_instant())
|
||||
return;
|
||||
|
||||
if(steps > 0.5)
|
||||
_sampling_bar->hori_knob(-1);
|
||||
else if (steps < -0.5)
|
||||
_sampling_bar->hori_knob(1);
|
||||
}
|
||||
|
||||
_offset = floor((_offset + offset) * (_preScale / _scale) - offset);
|
||||
@@ -320,6 +294,14 @@ void View::zoom(double steps, int offset)
|
||||
//}
|
||||
}
|
||||
|
||||
void View::hori_res_changed(double hori_res)
|
||||
{
|
||||
if (hori_res > 0) {
|
||||
const double scale = hori_res * DS_CONF_DSO_HDIVS / SR_SEC(1) / get_view_width();
|
||||
set_scale_offset(scale, this->offset());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void View::set_scale_offset(double scale, int64_t offset)
|
||||
{
|
||||
@@ -769,24 +751,14 @@ bool View::viewportEvent(QEvent *e)
|
||||
|
||||
int View::headerWidth()
|
||||
{
|
||||
int headerWidth;
|
||||
int maxNameWidth = 25;
|
||||
int maxLeftWidth = 0;
|
||||
int maxRightWidth = 0;
|
||||
|
||||
QFont font = QApplication::font();
|
||||
QFontMetrics fm(font);
|
||||
int headerWidth = _header->get_nameEditWidth();
|
||||
|
||||
const vector< boost::shared_ptr<Trace> > traces(get_traces(ALL_VIEW));
|
||||
if (!traces.empty()){
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
maxNameWidth = max(fm.boundingRect(t->get_name()).width(), maxNameWidth);
|
||||
maxLeftWidth = max(t->get_leftWidth(), maxLeftWidth);
|
||||
maxRightWidth = max(t->get_rightWidth(), maxRightWidth);
|
||||
}
|
||||
if (!traces.empty()) {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
headerWidth = max(t->get_name_width() + t->get_leftWidth() + t->get_rightWidth(),
|
||||
headerWidth);
|
||||
}
|
||||
maxNameWidth = max(_header->get_nameEditWidth(), maxNameWidth);
|
||||
headerWidth = maxLeftWidth + maxNameWidth + maxRightWidth;
|
||||
|
||||
setViewportMargins(headerWidth, RulerHeight, 0, 0);
|
||||
|
||||
|
||||
@@ -182,11 +182,7 @@ public:
|
||||
int get_view_width();
|
||||
int get_view_height();
|
||||
|
||||
void update_sample(bool instant);
|
||||
|
||||
void set_sample_rate(uint64_t sample_rate, bool force = false);
|
||||
|
||||
void set_sample_limit(uint64_t sample_limit, bool force = false);
|
||||
void update_hori_res();
|
||||
|
||||
QString get_measure(QString option);
|
||||
|
||||
@@ -244,6 +240,8 @@ public slots:
|
||||
void repeat_unshow();
|
||||
// -- repeat
|
||||
void repeat_show();
|
||||
// -- hori resolution
|
||||
void hori_res_changed(double hori_res);
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
@@ -1140,6 +1140,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_EN));
|
||||
if (dsl_en_ch_num(sdi) != 0) {
|
||||
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, 0, SR_CONF_SAMPLERATE));
|
||||
devc->limit_samples = DSCOPE_MAX_DEPTH / dsl_en_ch_num(sdi);
|
||||
}
|
||||
}
|
||||
if (ret == SR_OK)
|
||||
|
||||
@@ -965,7 +965,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
sr_dbg("%s: setting Trigger Margin to %d failed",
|
||||
__func__, devc->trigger_margin);
|
||||
} else if (id == SR_CONF_SAMPLERATE) {
|
||||
if (devc->test_mode != SR_TEST_NONE) {
|
||||
if (devc->test_mode == SR_TEST_NONE) {
|
||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||
if(sdi->mode == DSO) {
|
||||
devc->sample_wide = (devc->cur_samplerate <= DSLOGIC_MAX_DSO_SAMPLERATE);
|
||||
|
||||
@@ -684,6 +684,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
} else if (id == SR_CONF_LIMIT_SAMPLES) {
|
||||
devc->limit_msec = 0;
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
devc->limit_samples = (devc->limit_samples + 63) & ~63;
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
if (sdi->mode == DSO && en_ch_num(sdi) == 1) {
|
||||
devc->limit_samples /= 2;
|
||||
|
||||
@@ -89,6 +89,19 @@ enum {
|
||||
|
||||
#define SR_HZ_TO_NS(n) ((uint64_t)(1000000000ULL) / (n))
|
||||
|
||||
#define SR_NS(n) (n)
|
||||
#define SR_US(n) ((n) * (uint64_t)(1000ULL))
|
||||
#define SR_MS(n) ((n) * (uint64_t)(1000000ULL))
|
||||
#define SR_SEC(n) ((n) * (uint64_t)(1000000000ULL))
|
||||
#define SR_MIN(n) ((n) * (uint64_t)(60000000000ULL))
|
||||
#define SR_HOUR(n) ((n) * (uint64_t)(3600000000000ULL))
|
||||
#define SR_DAY(n) ((n) * (uint64_t)(86400000000000ULL))
|
||||
|
||||
#define SR_n(n) (n)
|
||||
#define SR_Kn(n) ((n) * (uint64_t)(1000ULL))
|
||||
#define SR_Mn(n) ((n) * (uint64_t)(1000000ULL))
|
||||
#define SR_Gn(n) ((n) * (uint64_t)(1000000000ULL))
|
||||
|
||||
#define SR_B(n) (n)
|
||||
#define SR_KB(n) ((n) * (uint64_t)(1024ULL))
|
||||
#define SR_MB(n) ((n) * (uint64_t)(1048576ULL))
|
||||
|
||||
@@ -38,7 +38,6 @@ struct context {
|
||||
double *channel_vpos;
|
||||
double *channel_mmin;
|
||||
double *channel_mmax;
|
||||
uint64_t timebase;
|
||||
uint64_t mask;
|
||||
uint64_t pre_data;
|
||||
uint64_t index;
|
||||
@@ -73,7 +72,6 @@ static int init(struct sr_output *o, GHashTable *options)
|
||||
ctx->mask = 0;
|
||||
ctx->index = 0;
|
||||
ctx->type = g_variant_get_int16(g_hash_table_lookup(options, "type"));
|
||||
ctx->timebase = g_variant_get_uint64(g_hash_table_lookup(options, "timebase"));
|
||||
|
||||
/* Get the number of channels, and the unitsize. */
|
||||
for (l = o->sdi->channels; l; l = l->next) {
|
||||
|
||||
@@ -235,12 +235,18 @@ SR_API char *sr_time_string(uint64_t time)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (time >= 1000000000)
|
||||
r = snprintf(o, 30, "%" PRIu64 " s", time / 1000000000);
|
||||
else if (time >= 1000000)
|
||||
r = snprintf(o, 30, "%" PRIu64 " ms", time / 1000000);
|
||||
else if (time >= 1000)
|
||||
r = snprintf(o, 30, "%" PRIu64 " us", time / 1000);
|
||||
if (time >= SR_DAY(1))
|
||||
r = snprintf(o, 30, "%0.2lf day", time * 1.0 / SR_DAY(1));
|
||||
else if (time >= SR_HOUR(1))
|
||||
r = snprintf(o, 30, "%0.2lf hour", time * 1.0 / SR_HOUR(1));
|
||||
else if (time >= SR_MIN(1))
|
||||
r = snprintf(o, 30, "%0.2lf min", time * 1.0 / SR_MIN(1));
|
||||
else if (time >= SR_SEC(1))
|
||||
r = snprintf(o, 30, "%0.2lf s", time * 1.0 / SR_SEC(1));
|
||||
else if (time >= SR_MS(1))
|
||||
r = snprintf(o, 30, "%0.2lf ms", time * 1.0 / SR_MS(1));
|
||||
else if (time >= SR_US(1))
|
||||
r = snprintf(o, 30, "%0.2lf us", time * 1.0 / SR_US(1));
|
||||
else
|
||||
r = snprintf(o, 30, "%" PRIu64 " ns", time);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user