Merge branch 'release-v0.95'
Conflicts: NEWS
@@ -103,7 +103,7 @@ set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab")
|
||||
|
||||
set(DS_VERSION_MAJOR 0)
|
||||
set(DS_VERSION_MINOR 9)
|
||||
set(DS_VERSION_MICRO 4)
|
||||
set(DS_VERSION_MICRO 5)
|
||||
set(DS_VERSION_STRING
|
||||
${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}
|
||||
)
|
||||
@@ -144,6 +144,7 @@ set(DSView_SOURCES
|
||||
pv/dialogs/storeprogress.cpp
|
||||
pv/dialogs/streamoptions.cpp
|
||||
pv/dialogs/waitingdialog.cpp
|
||||
pv/dialogs/dsomeasure.cpp
|
||||
pv/dock/dsotriggerdock.cpp
|
||||
pv/dock/measuredock.cpp
|
||||
pv/dock/searchdock.cpp
|
||||
@@ -189,6 +190,7 @@ set(DSView_HEADERS
|
||||
pv/dialogs/storeprogress.h
|
||||
pv/dialogs/streamoptions.h
|
||||
pv/dialogs/waitingdialog.h
|
||||
pv/dialogs/dsomeasure.h
|
||||
pv/dock/dsotriggerdock.h
|
||||
pv/dock/measuredock.h
|
||||
pv/dock/searchdock.h
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
<file>icons/start.png</file>
|
||||
<file>icons/dsl_logo.png</file>
|
||||
<file>icons/logo.png</file>
|
||||
<file>icons/decoder-hidden.png</file>
|
||||
<file>icons/decoder-shown.png</file>
|
||||
<file>icons/hidden.png</file>
|
||||
<file>icons/shown.png</file>
|
||||
<file>icons/instant.png</file>
|
||||
<file>icons/trigger_dis.png</file>
|
||||
<file>icons/file_dis.png</file>
|
||||
@@ -55,5 +55,6 @@
|
||||
<file>icons/instant_dis_cn.png</file>
|
||||
<file>icons/start_dis.png</file>
|
||||
<file>icons/start_dis_cn.png</file>
|
||||
<file>icons/settings.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -3,4 +3,6 @@ rm ./cmake_install.cmake
|
||||
rm -r ./CMakeFiles
|
||||
rm ./Makefile
|
||||
rm ./CMakeCache.txt
|
||||
find . -name 'moc_*.cpp*' | xargs rm -rf
|
||||
find . -name 'qrc_*.cpp' | xargs rm -rf
|
||||
echo "rm cmake cache end..."
|
||||
|
||||
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 954 B |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 860 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1012 B |
|
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 641 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.0 KiB |
BIN
DSView/icons/hidden.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1002 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 699 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 681 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 967 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 931 B |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 313 B |
BIN
DSView/icons/settings.png
Executable file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
DSView/icons/shown.png
Normal file
|
After Width: | Height: | Size: 883 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 789 B After Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 840 B |
|
Before Width: | Height: | Size: 978 B After Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -47,7 +47,7 @@ const float AnalogSnapshot::LogEnvelopeScaleFactor =
|
||||
const uint64_t AnalogSnapshot::EnvelopeDataUnit = 64*1024; // bytes
|
||||
|
||||
AnalogSnapshot::AnalogSnapshot(const sr_datafeed_analog &analog, uint64_t _total_sample_len, unsigned int channel_num) :
|
||||
Snapshot(sizeof(uint16_t), _total_sample_len, channel_num)
|
||||
Snapshot(sizeof(uint16_t)*channel_num, _total_sample_len, channel_num)
|
||||
{
|
||||
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
|
||||
memset(_envelope_levels, 0, sizeof(_envelope_levels));
|
||||
@@ -66,7 +66,7 @@ void AnalogSnapshot::append_payload(
|
||||
const sr_datafeed_analog &analog)
|
||||
{
|
||||
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
|
||||
append_data(analog.data, analog.num_samples);
|
||||
append_data(analog.data, analog.num_samples);
|
||||
|
||||
// Generate the first mip-map from the data
|
||||
append_payload_to_envelope_levels();
|
||||
|
||||
@@ -40,15 +40,20 @@ Annotation::Annotation(const srd_proto_data *const pdata) :
|
||||
(const srd_proto_data_annotation*)pdata->data;
|
||||
assert(pda);
|
||||
|
||||
_format = pda->ann_class;
|
||||
_format = pda->ann_class;
|
||||
|
||||
const char *const *annotations = (char**)pda->ann_text;
|
||||
const char *const *annotations = (char**)pda->ann_text;
|
||||
while(*annotations) {
|
||||
_annotations.push_back(QString::fromUtf8(*annotations));
|
||||
_annotations.push_back(QString::fromUtf8(*annotations));
|
||||
annotations++;
|
||||
}
|
||||
}
|
||||
|
||||
Annotation::~Annotation()
|
||||
{
|
||||
_annotations.clear();
|
||||
}
|
||||
|
||||
uint64_t Annotation::start_sample() const
|
||||
{
|
||||
return _start_sample;
|
||||
|
||||
@@ -35,6 +35,7 @@ class Annotation
|
||||
{
|
||||
public:
|
||||
Annotation(const srd_proto_data *const pdata);
|
||||
~Annotation();
|
||||
|
||||
uint64_t start_sample() const;
|
||||
uint64_t end_sample() const;
|
||||
|
||||
@@ -46,6 +46,10 @@ Decoder::~Decoder()
|
||||
for (map<string, GVariant*>::const_iterator i = _options.begin();
|
||||
i != _options.end(); i++)
|
||||
g_variant_unref((*i).second);
|
||||
|
||||
for (map<string, GVariant*>::const_iterator i = _options_back.begin();
|
||||
i != _options_back.end(); i++)
|
||||
g_variant_unref((*i).second);
|
||||
}
|
||||
|
||||
const srd_decoder* Decoder::decoder() const
|
||||
@@ -130,6 +134,7 @@ set< shared_ptr<pv::data::Logic> > Decoder::get_data()
|
||||
|
||||
srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_size) const
|
||||
{
|
||||
(void)unit_size;
|
||||
GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash,
|
||||
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
|
||||
|
||||
@@ -164,7 +169,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si
|
||||
g_hash_table_insert(probes, (*i).first->id, gvar);
|
||||
}
|
||||
|
||||
srd_inst_channel_set_all(decoder_inst, probes, unit_size);
|
||||
srd_inst_channel_set_all(decoder_inst, probes);
|
||||
|
||||
return decoder_inst;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row) :
|
||||
{
|
||||
}
|
||||
|
||||
Row::~Row()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const srd_decoder* Row::decoder() const
|
||||
{
|
||||
return _decoder;
|
||||
|
||||
@@ -36,6 +36,7 @@ class Row
|
||||
{
|
||||
public:
|
||||
Row();
|
||||
~Row();
|
||||
|
||||
Row(const srd_decoder *decoder,
|
||||
const srd_decoder_annotation_row *row = NULL);
|
||||
|
||||
@@ -34,6 +34,11 @@ RowData::RowData() :
|
||||
{
|
||||
}
|
||||
|
||||
RowData::~RowData()
|
||||
{
|
||||
_annotations.clear();
|
||||
}
|
||||
|
||||
uint64_t RowData::get_max_sample() const
|
||||
{
|
||||
if (_annotations.empty())
|
||||
|
||||
@@ -33,6 +33,7 @@ class RowData
|
||||
{
|
||||
public:
|
||||
RowData();
|
||||
~RowData();
|
||||
|
||||
public:
|
||||
uint64_t get_max_sample() const;
|
||||
|
||||
@@ -88,6 +88,8 @@ DecoderStack::~DecoderStack()
|
||||
// _decode_thread.join();
|
||||
// }
|
||||
stop_decode();
|
||||
_stack.clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
const std::list< boost::shared_ptr<decode::Decoder> >&
|
||||
@@ -335,7 +337,7 @@ void DecoderStack::decode_data(
|
||||
{
|
||||
//uint8_t chunk[DecodeChunkLength];
|
||||
uint8_t *chunk = NULL;
|
||||
chunk = (uint8_t *)realloc(chunk, DecodeChunkLength);
|
||||
//chunk = (uint8_t *)realloc(chunk, DecodeChunkLength);
|
||||
|
||||
const uint64_t chunk_sample_count =
|
||||
DecodeChunkLength / _snapshot->unit_size();
|
||||
@@ -349,10 +351,10 @@ void DecoderStack::decode_data(
|
||||
|
||||
const uint64_t chunk_end = min(
|
||||
i + chunk_sample_count, sample_count);
|
||||
_snapshot->get_samples(chunk, i, chunk_end);
|
||||
chunk = _snapshot->get_samples(i, chunk_end);
|
||||
|
||||
if (srd_session_send(session, i, i + sample_count, chunk,
|
||||
(chunk_end - i) * unit_size) != SRD_OK) {
|
||||
(chunk_end - i) * unit_size, unit_size) != SRD_OK) {
|
||||
_error_message = tr("Decoder reported an error");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
|
||||
QString _error_message;
|
||||
|
||||
std::auto_ptr<boost::thread> _decode_thread;
|
||||
std::unique_ptr<boost::thread> _decode_thread;
|
||||
decode_state _decode_state;
|
||||
|
||||
bool _options_changed;
|
||||
|
||||
@@ -45,6 +45,8 @@ const float DsoSnapshot::LogEnvelopeScaleFactor =
|
||||
logf(EnvelopeScaleFactor);
|
||||
const uint64_t DsoSnapshot::EnvelopeDataUnit = 4*1024; // bytes
|
||||
|
||||
const int DsoSnapshot::VrmsScaleFactor = 1 << 8;
|
||||
|
||||
DsoSnapshot::DsoSnapshot(const sr_datafeed_dso &dso, uint64_t _total_sample_len, unsigned int channel_num, bool instant) :
|
||||
Snapshot(sizeof(uint16_t), _total_sample_len, channel_num),
|
||||
_envelope_en(false),
|
||||
@@ -73,14 +75,14 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso)
|
||||
|
||||
// Generate the first mip-map from the data
|
||||
if (_envelope_en)
|
||||
append_payload_to_envelope_levels();
|
||||
append_payload_to_envelope_levels(dso.samplerate_tog);
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSnapshot::enable_envelope(bool enable)
|
||||
{
|
||||
if (!_envelope_done & enable)
|
||||
append_payload_to_envelope_levels();
|
||||
if (!_envelope_done && enable)
|
||||
append_payload_to_envelope_levels(true);
|
||||
_envelope_en = enable;
|
||||
}
|
||||
|
||||
@@ -144,26 +146,25 @@ void DsoSnapshot::reallocate_envelope(Envelope &e)
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSnapshot::append_payload_to_envelope_levels()
|
||||
void DsoSnapshot::append_payload_to_envelope_levels(bool header)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < _channel_num; i++) {
|
||||
for (unsigned int i = 0; i < _channel_num; i++) {
|
||||
Envelope &e0 = _envelope_levels[i][0];
|
||||
uint64_t prev_length;
|
||||
EnvelopeSample *dest_ptr;
|
||||
|
||||
// Expand the data buffer to fit the new samples
|
||||
prev_length = e0.length;
|
||||
e0.length = get_sample_count() / EnvelopeScaleFactor;
|
||||
if (header)
|
||||
prev_length = 0;
|
||||
else
|
||||
prev_length = e0.length;
|
||||
e0.length = _sample_count / EnvelopeScaleFactor;
|
||||
|
||||
// Break off if there are no new samples to compute
|
||||
// if (e0.length == prev_length)
|
||||
// return;
|
||||
if (e0.length == 0)
|
||||
return;
|
||||
if (e0.length == prev_length)
|
||||
prev_length = 0;
|
||||
|
||||
// Expand the data buffer to fit the new samples
|
||||
reallocate_envelope(e0);
|
||||
|
||||
dest_ptr = e0.samples + prev_length;
|
||||
@@ -171,17 +172,6 @@ void DsoSnapshot::append_payload_to_envelope_levels()
|
||||
// Iterate through the samples to populate the first level mipmap
|
||||
const uint8_t *const stop_src_ptr = (uint8_t*)_data +
|
||||
e0.length * EnvelopeScaleFactor * _channel_num;
|
||||
// for (const uint16_t *src_ptr = (uint16_t*)_data +
|
||||
// prev_length * EnvelopeScaleFactor;
|
||||
// src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor)
|
||||
// {
|
||||
// const EnvelopeSample sub_sample = {
|
||||
// *min_element(src_ptr, src_ptr + EnvelopeScaleFactor),
|
||||
// *max_element(src_ptr, src_ptr + EnvelopeScaleFactor),
|
||||
// };
|
||||
|
||||
// *dest_ptr++ = sub_sample;
|
||||
// }
|
||||
for (const uint8_t *src_ptr = (uint8_t*)_data +
|
||||
prev_length * EnvelopeScaleFactor * _channel_num + i;
|
||||
src_ptr < stop_src_ptr; src_ptr += EnvelopeScaleFactor * _channel_num)
|
||||
@@ -194,14 +184,13 @@ void DsoSnapshot::append_payload_to_envelope_levels()
|
||||
EnvelopeSample sub_sample;
|
||||
sub_sample.min = *begin_src_ptr;
|
||||
sub_sample.max = *begin_src_ptr;
|
||||
begin_src_ptr += _channel_num;
|
||||
//begin_src_ptr += _channel_num;
|
||||
while (begin_src_ptr < end_src_ptr)
|
||||
{
|
||||
sub_sample.min = min(sub_sample.min, *begin_src_ptr);
|
||||
sub_sample.max = max(sub_sample.max, *begin_src_ptr);
|
||||
begin_src_ptr += _channel_num;
|
||||
}
|
||||
|
||||
*dest_ptr++ = sub_sample;
|
||||
}
|
||||
|
||||
@@ -248,5 +237,72 @@ void DsoSnapshot::append_payload_to_envelope_levels()
|
||||
_envelope_done = true;
|
||||
}
|
||||
|
||||
double DsoSnapshot::cal_vrms(double zero_off, int index) const
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < _channel_num);
|
||||
|
||||
// root-meam-squart value
|
||||
double vrms_pre = 0;
|
||||
double vrms = 0;
|
||||
double tmp;
|
||||
|
||||
// Iterate through the samples to populate the first level mipmap
|
||||
const uint8_t *const stop_src_ptr = (uint8_t*)_data +
|
||||
_sample_count * _channel_num;
|
||||
for (const uint8_t *src_ptr = (uint8_t*)_data + index;
|
||||
src_ptr < stop_src_ptr; src_ptr += VrmsScaleFactor * _channel_num)
|
||||
{
|
||||
const uint8_t * begin_src_ptr =
|
||||
src_ptr;
|
||||
const uint8_t *const end_src_ptr =
|
||||
src_ptr + VrmsScaleFactor * _channel_num;
|
||||
|
||||
while (begin_src_ptr < end_src_ptr)
|
||||
{
|
||||
tmp = (zero_off - *begin_src_ptr);
|
||||
vrms += tmp * tmp;
|
||||
begin_src_ptr += _channel_num;
|
||||
}
|
||||
vrms = vrms_pre + vrms / _sample_count;
|
||||
vrms_pre = vrms;
|
||||
}
|
||||
vrms = std::pow(vrms, 0.5);
|
||||
|
||||
return vrms;
|
||||
}
|
||||
|
||||
double DsoSnapshot::cal_vmean(int index) const
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < _channel_num);
|
||||
|
||||
// mean value
|
||||
double vmean_pre = 0;
|
||||
double vmean = 0;
|
||||
|
||||
// Iterate through the samples to populate the first level mipmap
|
||||
const uint8_t *const stop_src_ptr = (uint8_t*)_data +
|
||||
_sample_count * _channel_num;
|
||||
for (const uint8_t *src_ptr = (uint8_t*)_data + index;
|
||||
src_ptr < stop_src_ptr; src_ptr += VrmsScaleFactor * _channel_num)
|
||||
{
|
||||
const uint8_t * begin_src_ptr =
|
||||
src_ptr;
|
||||
const uint8_t *const end_src_ptr =
|
||||
src_ptr + VrmsScaleFactor * _channel_num;
|
||||
|
||||
while (begin_src_ptr < end_src_ptr)
|
||||
{
|
||||
vmean += *begin_src_ptr;
|
||||
begin_src_ptr += _channel_num;
|
||||
}
|
||||
vmean = vmean_pre + vmean / _sample_count;
|
||||
vmean_pre = vmean;
|
||||
}
|
||||
|
||||
return vmean;
|
||||
}
|
||||
|
||||
} // namespace data
|
||||
} // namespace pv
|
||||
|
||||
@@ -67,6 +67,8 @@ private:
|
||||
static const float LogEnvelopeScaleFactor;
|
||||
static const uint64_t EnvelopeDataUnit;
|
||||
|
||||
static const int VrmsScaleFactor;
|
||||
|
||||
public:
|
||||
DsoSnapshot(const sr_datafeed_dso &dso, uint64_t _total_sample_len, unsigned int channel_num, bool instant);
|
||||
|
||||
@@ -82,10 +84,13 @@ public:
|
||||
|
||||
void enable_envelope(bool enable);
|
||||
|
||||
double cal_vrms(double zero_off, int index) const;
|
||||
double cal_vmean(int index) const;
|
||||
|
||||
private:
|
||||
void reallocate_envelope(Envelope &l);
|
||||
|
||||
void append_payload_to_envelope_levels();
|
||||
void append_payload_to_envelope_levels(bool header);
|
||||
|
||||
private:
|
||||
struct Envelope _envelope_levels[2*DS_MAX_DSO_PROBES_NUM][ScaleStepCount];
|
||||
|
||||
@@ -61,6 +61,37 @@ GroupSnapshot::GroupSnapshot(const boost::shared_ptr<LogicSnapshot> &_logic_snap
|
||||
_sample_count = _logic_snapshot->get_sample_count();
|
||||
_unit_size = _logic_snapshot->unit_size();
|
||||
_index_list = index_list;
|
||||
|
||||
_mask = 0;
|
||||
std::list<int>::iterator j = _index_list.begin();
|
||||
while(j != _index_list.end())
|
||||
_mask |= value_mask[(*j++)];
|
||||
|
||||
for (int i=0; i<32; i++) {
|
||||
_bubble_start[i] = -1;
|
||||
_bubble_end[i] = -1;
|
||||
}
|
||||
uint16_t mask = _mask;
|
||||
int i = 0;
|
||||
int k = 0;
|
||||
int zero = 0;
|
||||
int zero_pre = 0;
|
||||
// max bubble count: 31
|
||||
do {
|
||||
if (mask & 0x1) {
|
||||
if (_bubble_start[k] != -1 &&
|
||||
_bubble_end[k] == -1)
|
||||
_bubble_end[k++] = i - zero_pre;
|
||||
} else {
|
||||
if (_bubble_start[k] == -1) {
|
||||
_bubble_start[k] = i - zero;
|
||||
zero_pre = zero;
|
||||
}
|
||||
zero++;
|
||||
}
|
||||
i++;
|
||||
}while(mask >>= 1);
|
||||
|
||||
append_payload();
|
||||
}
|
||||
|
||||
@@ -95,21 +126,25 @@ const uint16_t* GroupSnapshot::get_samples(
|
||||
assert(start_sample <= end_sample);
|
||||
|
||||
int64_t i;
|
||||
uint64_t pow;
|
||||
uint16_t tmpl, tmpr;
|
||||
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
|
||||
|
||||
uint16_t *const data = new uint16_t[end_sample - start_sample];
|
||||
// memcpy(data, (uint16_t*)_data + start_sample, sizeof(uint16_t) *
|
||||
// (end_sample - start_sample));
|
||||
memset(data, 0, sizeof(uint16_t) * (end_sample - start_sample));
|
||||
// memset(data, 0, sizeof(uint16_t) * (end_sample - start_sample));
|
||||
for(i = start_sample; i < end_sample; i++) {
|
||||
std::list<int>::iterator j = _index_list.begin();
|
||||
pow = 0;
|
||||
while(j != _index_list.end()) {
|
||||
*(data + i - start_sample) += ((*((uint16_t*)_data + i) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
pow++;
|
||||
j++;
|
||||
if (_unit_size == 2)
|
||||
tmpl = *((uint16_t*)_data + i) & _mask;
|
||||
else
|
||||
tmpl = *((uint8_t*)_data + i) & _mask;
|
||||
for(int j=0; _bubble_start[j] != -1; j++) {
|
||||
tmpr = tmpl & (0xffff >> (16 - _bubble_start[j]));
|
||||
tmpl >>= _bubble_end[j];
|
||||
tmpl <<= _bubble_start[j];
|
||||
tmpl += tmpr;
|
||||
}
|
||||
*(data + i - start_sample) = tmpl;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -170,61 +205,26 @@ void GroupSnapshot::append_payload_to_envelope_levels()
|
||||
|
||||
// Iterate through the samples to populate the first level mipmap
|
||||
uint16_t group_value[EnvelopeScaleFactor];
|
||||
const uint16_t *const end_src_ptr = (uint16_t*)_data +
|
||||
e0.length * EnvelopeScaleFactor;
|
||||
for (const uint16_t *src_ptr = (uint16_t*)_data +
|
||||
prev_length * EnvelopeScaleFactor;
|
||||
src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor)
|
||||
const uint8_t *const end_src_ptr = (uint8_t*)_data +
|
||||
e0.length * EnvelopeScaleFactor * _unit_size;
|
||||
for (const uint8_t *src_ptr = (uint8_t*)_data +
|
||||
prev_length * EnvelopeScaleFactor * _unit_size;
|
||||
src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor * _unit_size)
|
||||
{
|
||||
int pow;
|
||||
// for(i = 0; i < EnvelopeScaleFactor; i++) {
|
||||
// group_value[i] = 0;
|
||||
// std::list<int>::iterator j = _index_list.begin();
|
||||
// pow = 0;
|
||||
// while(j != _index_list.end()) {
|
||||
// group_value[i] += ((*(src_ptr + i) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
// pow++;
|
||||
// j++;
|
||||
// }
|
||||
// }
|
||||
group_value[0] = 0;
|
||||
group_value[1] = 0;
|
||||
group_value[2] = 0;
|
||||
group_value[3] = 0;
|
||||
group_value[4] = 0;
|
||||
group_value[5] = 0;
|
||||
group_value[6] = 0;
|
||||
group_value[7] = 0;
|
||||
group_value[8] = 0;
|
||||
group_value[9] = 0;
|
||||
group_value[10] = 0;
|
||||
group_value[11] = 0;
|
||||
group_value[12] = 0;
|
||||
group_value[13] = 0;
|
||||
group_value[14] = 0;
|
||||
group_value[15] = 0;
|
||||
std::list<int>::iterator j = _index_list.begin();
|
||||
pow = 0;
|
||||
while(j != _index_list.end()) {
|
||||
group_value[0] += ((*(src_ptr + 0) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[1] += ((*(src_ptr + 1) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[2] += ((*(src_ptr + 2) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[3] += ((*(src_ptr + 3) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[4] += ((*(src_ptr + 4) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[5] += ((*(src_ptr + 5) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[6] += ((*(src_ptr + 6) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[7] += ((*(src_ptr + 7) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[8] += ((*(src_ptr + 8) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[9] += ((*(src_ptr + 9) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[10] += ((*(src_ptr + 10) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[11] += ((*(src_ptr + 11) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[12] += ((*(src_ptr + 12) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[13] += ((*(src_ptr + 13) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[14] += ((*(src_ptr + 14) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
group_value[15] += ((*(src_ptr + 15) & value_mask[(*j)]) >> ((*j) - pow));
|
||||
pow++;
|
||||
j++;
|
||||
uint16_t tmpr;
|
||||
for(int i = 0; i < EnvelopeScaleFactor; i++) {
|
||||
if (_unit_size == 2)
|
||||
group_value[i] = *((uint16_t*)src_ptr + i) & _mask;
|
||||
else
|
||||
group_value[i] = *((uint8_t*)src_ptr + i) & _mask;
|
||||
for(int j=0; _bubble_start[j] != -1; j++) {
|
||||
tmpr = group_value[i] & (0xffff >> (16 - _bubble_start[j]));
|
||||
group_value[i] >>= _bubble_end[j];
|
||||
group_value[i] <<= _bubble_start[j];
|
||||
group_value[i] += tmpr;
|
||||
}
|
||||
}
|
||||
|
||||
const EnvelopeSample sub_sample = {
|
||||
*min_element(group_value, group_value + EnvelopeScaleFactor),
|
||||
*max_element(group_value, group_value + EnvelopeScaleFactor),
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
static const unsigned int ScaleStepCount = 10;
|
||||
static const unsigned int ScaleStepCount = 16;
|
||||
static const int EnvelopeScalePower;
|
||||
static const int EnvelopeScaleFactor;
|
||||
static const float LogEnvelopeScaleFactor;
|
||||
@@ -103,6 +103,9 @@ private:
|
||||
int _unit_size;
|
||||
boost::shared_ptr<view::Signal> _signal;
|
||||
std::list<int> _index_list;
|
||||
uint16_t _mask;
|
||||
int _bubble_start[32];
|
||||
int _bubble_end[32];
|
||||
|
||||
friend class GroupSnapshotTest::Basic;
|
||||
};
|
||||
|
||||
@@ -74,20 +74,21 @@ void LogicSnapshot::append_payload(
|
||||
append_payload_to_mipmap();
|
||||
}
|
||||
|
||||
void LogicSnapshot::get_samples(uint8_t *const data,
|
||||
int64_t start_sample, int64_t end_sample) const
|
||||
uint8_t * LogicSnapshot::get_samples(int64_t start_sample, int64_t end_sample) const
|
||||
{
|
||||
assert(data);
|
||||
//assert(data);
|
||||
assert(start_sample >= 0);
|
||||
assert(start_sample <= (int64_t)_sample_count);
|
||||
assert(end_sample >= 0);
|
||||
assert(end_sample <= (int64_t)_sample_count);
|
||||
assert(start_sample <= end_sample);
|
||||
|
||||
(void)end_sample;
|
||||
//lock_guard<recursive_mutex> lock(_mutex);
|
||||
|
||||
const size_t size = (end_sample - start_sample) * _unit_size;
|
||||
memcpy(data, (const uint8_t*)_data + start_sample * _unit_size, size);
|
||||
//const size_t size = (end_sample - start_sample) * _unit_size;
|
||||
//memcpy(data, (const uint8_t*)_data + start_sample * _unit_size, size);
|
||||
return (uint8_t*)_data + start_sample * _unit_size;
|
||||
}
|
||||
|
||||
void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m)
|
||||
@@ -192,9 +193,7 @@ void LogicSnapshot::get_subsampled_edges(
|
||||
float min_length, int sig_index)
|
||||
{
|
||||
uint64_t index = start;
|
||||
unsigned int level;
|
||||
bool last_sample;
|
||||
bool fast_forward;
|
||||
|
||||
assert(end <= get_sample_count());
|
||||
assert(start <= end);
|
||||
@@ -254,7 +253,7 @@ bool LogicSnapshot::get_nxt_edge(
|
||||
unsigned int level;
|
||||
bool fast_forward;
|
||||
|
||||
assert(index > 0);
|
||||
//assert(index > 0);
|
||||
|
||||
const unsigned int min_level = max((int)floorf(logf(min_length) /
|
||||
LogMipMapScaleFactor) - 1, 0);
|
||||
@@ -447,9 +446,9 @@ bool LogicSnapshot::get_pre_edge(
|
||||
// If resolution is less than a mip map block,
|
||||
// round up to the beginning of the mip-map block
|
||||
// for this level of detail
|
||||
const int min_level_scale_power =
|
||||
const unsigned int min_level_scale_power =
|
||||
(level + 1) * MipMapScalePower;
|
||||
if (index < (1 << min_level_scale_power))
|
||||
if (index < (uint64_t)(1 << min_level_scale_power))
|
||||
index = 0;
|
||||
else
|
||||
index = pow2_ceil(index, min_level_scale_power) - (1 << min_level_scale_power) - 1;
|
||||
@@ -539,16 +538,13 @@ bool LogicSnapshot::get_pre_edge(
|
||||
// do a linear search for the next transition within the
|
||||
// block
|
||||
if (min_length < MipMapScaleFactor) {
|
||||
for (; index >= 0; index--) {
|
||||
for (; index > 0; index--) {
|
||||
const bool sample = (get_sample(index) &
|
||||
sig_mask) != 0;
|
||||
if (sample != last_sample) {
|
||||
index++;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,7 @@ public:
|
||||
|
||||
void append_payload(const sr_datafeed_logic &logic);
|
||||
|
||||
void get_samples(uint8_t *const data,
|
||||
int64_t start_sample, int64_t end_sample) const;
|
||||
uint8_t * get_samples(int64_t start_sample, int64_t end_sample) const;
|
||||
|
||||
private:
|
||||
void reallocate_mipmap_level(MipMapLevel &m);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "inputfile.h"
|
||||
#include "sessionfile.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <libsigrok4DSL/libsigrok.h>
|
||||
@@ -39,7 +41,8 @@ File::File(QString path) :
|
||||
|
||||
QString File::format_device_title() const
|
||||
{
|
||||
return _path;
|
||||
QFileInfo fi(_path);
|
||||
return fi.fileName();
|
||||
}
|
||||
|
||||
File* File::create(QString name)
|
||||
|
||||
@@ -102,7 +102,7 @@ std::list<boost::shared_ptr<device::DevInst> > DeviceManager::driver_scan(
|
||||
//release_driver(driver);
|
||||
|
||||
// Check If DSL hardware driver
|
||||
if (strcmp(driver->name, "demo") != 0) {
|
||||
if (strncmp(driver->name, "virtual", 7)) {
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
if (!dir.cd("res"))
|
||||
return driver_devices;
|
||||
|
||||
@@ -41,7 +41,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
|
||||
QDialog(parent),
|
||||
_dev_inst(dev_inst),
|
||||
_layout(this),
|
||||
_button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
||||
_button_box(QDialogButtonBox::Ok,
|
||||
Qt::Horizontal, this),
|
||||
_device_options_binding(_dev_inst->dev_inst())
|
||||
{
|
||||
@@ -68,7 +68,16 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
|
||||
_layout.addWidget(&_button_box);
|
||||
|
||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
//connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
||||
if (gvar != NULL) {
|
||||
_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
connect(&_mode_check, SIGNAL(timeout()), this, SLOT(mode_check()));
|
||||
_mode_check.setInterval(100);
|
||||
_mode_check.start();
|
||||
}
|
||||
|
||||
void DeviceOptions::accept()
|
||||
@@ -100,9 +109,7 @@ void DeviceOptions::accept()
|
||||
|
||||
void DeviceOptions::reject()
|
||||
{
|
||||
using namespace Qt;
|
||||
QDialog::reject();
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
QWidget* DeviceOptions::get_property_form()
|
||||
@@ -116,8 +123,11 @@ QWidget* DeviceOptions::get_property_form()
|
||||
BOOST_FOREACH(boost::shared_ptr<pv::prop::Property> p, properties)
|
||||
{
|
||||
assert(p);
|
||||
const QString label = p->labeled_widget() ? QString() : p->name();
|
||||
layout->addRow(label, p->get_widget(form));
|
||||
const QString label = p->labeled_widget() ? QString() : p->name();
|
||||
if (label == tr("Operation Mode"))
|
||||
layout->addRow(label, p->get_widget(form, true));
|
||||
else
|
||||
layout->addRow(label, p->get_widget(form));
|
||||
}
|
||||
|
||||
return form;
|
||||
@@ -127,8 +137,9 @@ void DeviceOptions::setup_probes()
|
||||
{
|
||||
using namespace Qt;
|
||||
|
||||
int row = 0, col = 0;
|
||||
int row0 = 0, row1 = 0, col = 0;
|
||||
int index = 0;
|
||||
QString ch_mode;
|
||||
|
||||
while(_probes_box_layout.count() > 0)
|
||||
{
|
||||
@@ -140,6 +151,30 @@ void DeviceOptions::setup_probes()
|
||||
_probes_label_list.clear();
|
||||
_probes_checkBox_list.clear();
|
||||
|
||||
if (_dev_inst->dev_inst()->mode == LOGIC) {
|
||||
GVariant *gvar_opts;
|
||||
gsize num_opts;
|
||||
if (sr_config_list(_dev_inst->dev_inst()->driver, _dev_inst->dev_inst(), NULL, SR_CONF_CHANNEL_MODE,
|
||||
&gvar_opts) == SR_OK) {
|
||||
const char **const options = g_variant_get_strv(gvar_opts, &num_opts);
|
||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_CHANNEL_MODE);
|
||||
if (gvar != NULL) {
|
||||
ch_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||
g_variant_unref(gvar);
|
||||
|
||||
for (unsigned int i=0; i<num_opts; i++){
|
||||
QRadioButton *ch_opts = new QRadioButton(options[i]);
|
||||
_probes_box_layout.addWidget(ch_opts, row0, col, 1, 8);
|
||||
connect(ch_opts, SIGNAL(pressed()), this, SLOT(channel_check()));
|
||||
row0++;
|
||||
if (QString::fromUtf8(options[i]) == ch_mode)
|
||||
ch_opts->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_variant_unref(gvar_opts);
|
||||
}
|
||||
|
||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
||||
sr_channel *const probe = (sr_channel*)l->data;
|
||||
assert(probe);
|
||||
@@ -147,14 +182,14 @@ void DeviceOptions::setup_probes()
|
||||
QLabel *probe_label = new QLabel(QString::number(probe->index), this);
|
||||
QCheckBox *probe_checkBox = new QCheckBox(this);
|
||||
probe_checkBox->setCheckState(probe->enabled ? Qt::Checked : Qt::Unchecked);
|
||||
_probes_box_layout.addWidget(probe_label, row * 2, col);
|
||||
_probes_box_layout.addWidget(probe_checkBox, row * 2 + 1, col);
|
||||
_probes_box_layout.addWidget(probe_label, row1 * 2 + row0, col);
|
||||
_probes_box_layout.addWidget(probe_checkBox, row1 * 2 + 1 + row0, col);
|
||||
_probes_label_list.push_back(probe_label);
|
||||
_probes_checkBox_list.push_back(probe_checkBox);
|
||||
|
||||
index++;
|
||||
col = index % 8;
|
||||
row = index / 8;
|
||||
row1 = index / 8;
|
||||
}
|
||||
|
||||
QPushButton *_enable_all_probes = new QPushButton(tr("Enable All"), this);
|
||||
@@ -165,8 +200,8 @@ void DeviceOptions::setup_probes()
|
||||
connect(_disable_all_probes, SIGNAL(clicked()),
|
||||
this, SLOT(disable_all_probes()));
|
||||
|
||||
_probes_box_layout.addWidget(_enable_all_probes, (row + 1) * 2, 0, 1, 4);
|
||||
_probes_box_layout.addWidget(_disable_all_probes, (row + 1) * 2, 4, 1, 4);
|
||||
_probes_box_layout.addWidget(_enable_all_probes, (row1 + 1) * 2 + row0, 0, 1, 4);
|
||||
_probes_box_layout.addWidget(_disable_all_probes, (row1 + 1) * 2 + row0, 4, 1, 4);
|
||||
}
|
||||
|
||||
void DeviceOptions::set_all_probes(bool set)
|
||||
@@ -206,5 +241,44 @@ void DeviceOptions::zero_adj()
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceOptions::mode_check()
|
||||
{
|
||||
bool test;
|
||||
QString mode;
|
||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
||||
if (gvar != NULL) {
|
||||
mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (mode != _mode) {
|
||||
setup_probes();
|
||||
_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_TEST);
|
||||
if (gvar != NULL) {
|
||||
test = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
|
||||
if (test) {
|
||||
QVector<QCheckBox *>::iterator i = _probes_checkBox_list.begin();
|
||||
while(i != _probes_checkBox_list.end()) {
|
||||
(*i)->setCheckState(Qt::Checked);
|
||||
(*i)->setDisabled(TRUE);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceOptions::channel_check()
|
||||
{
|
||||
QRadioButton* sc=dynamic_cast<QRadioButton*>(sender());
|
||||
if(sc != NULL)
|
||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(sc->text().toUtf8().data()));
|
||||
setup_probes();
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace pv
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QTimer>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
@@ -68,6 +69,8 @@ private slots:
|
||||
void enable_all_probes();
|
||||
void disable_all_probes();
|
||||
void zero_adj();
|
||||
void mode_check();
|
||||
void channel_check();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<pv::device::DevInst> _dev_inst;
|
||||
@@ -84,6 +87,9 @@ private:
|
||||
QPushButton *_config_button;
|
||||
QDialogButtonBox _button_box;
|
||||
|
||||
QTimer _mode_check;
|
||||
QString _mode;
|
||||
|
||||
pv::prop::binding::DeviceOptions _device_options_binding;
|
||||
};
|
||||
|
||||
|
||||
85
DSView/pv/dialogs/dsomeasure.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "dsomeasure.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QVariant>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using namespace pv::view;
|
||||
|
||||
namespace pv {
|
||||
namespace dialogs {
|
||||
|
||||
DsoMeasure::DsoMeasure(QWidget *parent, boost::shared_ptr<DsoSignal> dsoSig) :
|
||||
QDialog(parent),
|
||||
_dsoSig(dsoSig),
|
||||
_layout(this),
|
||||
_button_box(QDialogButtonBox::Ok,
|
||||
Qt::Horizontal, this)
|
||||
{
|
||||
setWindowTitle(tr("DSO Measure Options"));
|
||||
setLayout(&_layout);
|
||||
|
||||
for (int i=DsoSignal::DSO_MS_BEGIN+1; i<DsoSignal::DSO_MS_END; i++) {
|
||||
QCheckBox *checkBox = new QCheckBox(_dsoSig->get_ms_string(i), this);
|
||||
checkBox->setProperty("id", QVariant(i));
|
||||
checkBox->setChecked(dsoSig->get_ms_en(i));
|
||||
_layout.addWidget(checkBox);
|
||||
connect(checkBox, SIGNAL(toggled(bool)), this, SLOT(set_measure(bool)));
|
||||
}
|
||||
|
||||
_layout.addWidget(&_button_box);
|
||||
|
||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(&_button_box, SIGNAL(rejected()), this, SLOT(accept()));
|
||||
}
|
||||
|
||||
void DsoMeasure::set_measure(bool en)
|
||||
{
|
||||
(void)en;
|
||||
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
||||
if(sc != NULL) {
|
||||
QVariant id = sc->property("id");
|
||||
_dsoSig->set_ms_en(id.toInt(), sc->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
void DsoMeasure::accept()
|
||||
{
|
||||
using namespace Qt;
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void DsoMeasure::reject()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace pv
|
||||
67
DSView/pv/dialogs/dsomeasure.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
|
||||
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DSVIEW_PV_DSOMEASURE_H
|
||||
#define DSVIEW_PV_DSOMEASURE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <pv/view/dsosignal.h>
|
||||
|
||||
namespace pv {
|
||||
|
||||
namespace view {
|
||||
class DsoSignal;
|
||||
}
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
class DsoMeasure : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DsoMeasure(QWidget *parent, boost::shared_ptr<pv::view::DsoSignal> dsoSig);
|
||||
|
||||
private slots:
|
||||
void set_measure(bool en);
|
||||
|
||||
protected:
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<pv::view::DsoSignal> _dsoSig;
|
||||
|
||||
QVBoxLayout _layout;
|
||||
QDialogButtonBox _button_box;
|
||||
};
|
||||
|
||||
} // namespace dialogs
|
||||
} // namespace pv
|
||||
|
||||
#endif // DSVIEW_PV_DSOMEASURE_H
|
||||
@@ -48,7 +48,7 @@ Search::Search(QWidget *parent, struct sr_dev_inst *sdi, QString pattern) :
|
||||
search_lineEdit.setInputMask("X X X X X X X X X X X X X X X X");
|
||||
search_lineEdit.setFont(font);
|
||||
|
||||
QLabel *search_label = new QLabel("1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0");
|
||||
QLabel *search_label = new QLabel("1 1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0");
|
||||
search_label->setFont(font);
|
||||
|
||||
search_buttonBox.addButton(QDialogButtonBox::Ok);
|
||||
|
||||
@@ -116,7 +116,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
_inv1_comboBox->addItem(tr("!="));
|
||||
_inv1_comboBox_list.push_back(_inv1_comboBox);
|
||||
|
||||
QLabel *value_exp_label = new QLabel("1 1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0", _widget);
|
||||
QLabel *value_exp_label = new QLabel("1 1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ", _widget);
|
||||
QLabel *inv_exp_label = new QLabel("Inv", _widget);
|
||||
QLabel *count_exp_label = new QLabel("Counter", _widget);
|
||||
value_exp_label->setFont(font);
|
||||
@@ -147,11 +147,6 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
|
||||
connect(_value0_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
connect(_value1_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
connect(_logic_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(logic_changed(int)));
|
||||
connect(_inv0_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(inv_changed(int)));
|
||||
connect(_inv1_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(inv_changed(int)));
|
||||
connect(_count0_spinBox, SIGNAL(editingFinished()), this, SLOT(count_changed()));
|
||||
connect(_count1_spinBox, SIGNAL(editingFinished()), this, SLOT(count_changed()));
|
||||
}
|
||||
|
||||
_serial_start_label = new QLabel(tr("Start Flag: "), _widget);
|
||||
@@ -221,7 +216,6 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
connect(_serial_start_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
connect(_serial_stop_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
connect(_serial_edge_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
connect(_serial_data_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(serial_channel_changed(int)));
|
||||
connect(_serial_value_lineEdit, SIGNAL(editingFinished()), this, SLOT(value_changed()));
|
||||
|
||||
|
||||
@@ -233,9 +227,8 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
|
||||
connect(simple_radioButton, SIGNAL(clicked()), this, SLOT(simple_trigger()));
|
||||
connect(adv_radioButton, SIGNAL(clicked()), this, SLOT(adv_trigger()));
|
||||
connect(stages_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(trigger_stages_changed(int)));
|
||||
connect(position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int)));
|
||||
connect(_adv_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(adv_tog(int)));
|
||||
connect(stages_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(widget_enable(int)));
|
||||
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(_widget);
|
||||
QGridLayout *gLayout = new QGridLayout();
|
||||
@@ -256,7 +249,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) :
|
||||
_widget->setLayout(layout);
|
||||
|
||||
this->setWidget(_widget);
|
||||
_widget->setGeometry(0, 0, sizeHint().width(), 1000);
|
||||
//_widget->setGeometry(0, 0, sizeHint().width(), 1000);
|
||||
_widget->setObjectName("triggerWidget");
|
||||
}
|
||||
|
||||
@@ -274,25 +267,9 @@ void TriggerDock::paintEvent(QPaintEvent *)
|
||||
|
||||
void TriggerDock::simple_trigger()
|
||||
{
|
||||
int i;
|
||||
stages_label->setDisabled(true);
|
||||
stages_comboBox->setDisabled(true);
|
||||
_adv_tabWidget->setDisabled(true);
|
||||
for (i = 0; i < TriggerStages; i++) {
|
||||
stage_tabWidget->setTabEnabled(i, true);
|
||||
// _mu_label_list.at(i)->setDisabled(true);
|
||||
// _logic_comboBox_list.at(i)->setDisabled(true);
|
||||
|
||||
// _value0_lineEdit_list.at(i)->setDisabled(true);
|
||||
// _count0_spinBox_list.at(i)->setDisabled(true);
|
||||
// _inv0_comboBox_list.at(i)->setDisabled(true);
|
||||
|
||||
// _value1_lineEdit_list.at(i)->setDisabled(true);
|
||||
// _count1_spinBox_list.at(i)->setDisabled(true);
|
||||
// _inv1_comboBox_list.at(i)->setDisabled(true);
|
||||
}
|
||||
ds_trigger_set_mode(SIMPLE_TRIGGER);
|
||||
_session.set_adv_trigger(false);
|
||||
}
|
||||
|
||||
void TriggerDock::adv_trigger()
|
||||
@@ -313,12 +290,7 @@ void TriggerDock::adv_trigger()
|
||||
msg.exec();
|
||||
simple_radioButton->setChecked(true);
|
||||
} else {
|
||||
widget_enable();
|
||||
if (_adv_tabWidget->currentIndex() == 0)
|
||||
ds_trigger_set_mode(ADV_TRIGGER);
|
||||
else if (_adv_tabWidget->currentIndex() == 1)
|
||||
ds_trigger_set_mode(SERIAL_TRIGGER);
|
||||
_session.set_adv_trigger(true);
|
||||
widget_enable(0);
|
||||
}
|
||||
} else {
|
||||
QMessageBox msg(this);
|
||||
@@ -331,18 +303,10 @@ void TriggerDock::adv_trigger()
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::trigger_stages_changed(int index)
|
||||
void TriggerDock::widget_enable(int index)
|
||||
{
|
||||
widget_enable();
|
||||
ds_trigger_set_stage(index);
|
||||
value_changed();
|
||||
logic_changed(0);
|
||||
inv_changed(0);
|
||||
count_changed();
|
||||
}
|
||||
(void) index;
|
||||
|
||||
void TriggerDock::widget_enable()
|
||||
{
|
||||
int i;
|
||||
int enable_stages;
|
||||
stages_label->setDisabled(false);
|
||||
@@ -352,176 +316,133 @@ void TriggerDock::widget_enable()
|
||||
enable_stages = stages_comboBox->currentText().toInt();
|
||||
for (i = 0; i < enable_stages; i++) {
|
||||
stage_tabWidget->setTabEnabled(i, true);
|
||||
// _mu_label_list.at(i)->setVisible(true);
|
||||
// _mu_label_list.at(i)->setDisabled(false);
|
||||
// _logic_comboBox_list.at(i)->setVisible(true);
|
||||
// _logic_comboBox_list.at(i)->setDisabled(false);
|
||||
|
||||
// _value0_lineEdit_list.at(i)->setVisible(true);
|
||||
// _value0_lineEdit_list.at(i)->setDisabled(false);
|
||||
// _count0_spinBox_list.at(i)->setVisible(true);
|
||||
// _count0_spinBox_list.at(i)->setDisabled(false);
|
||||
// _inv0_comboBox_list.at(i)->setVisible(true);
|
||||
// _inv0_comboBox_list.at(i)->setDisabled(false);
|
||||
|
||||
// _value1_lineEdit_list.at(i)->setVisible(true);
|
||||
// _value1_lineEdit_list.at(i)->setDisabled(false);
|
||||
// _count1_spinBox_list.at(i)->setVisible(true);
|
||||
// _count1_spinBox_list.at(i)->setDisabled(false);
|
||||
// _inv1_comboBox_list.at(i)->setVisible(true);
|
||||
// _inv1_comboBox_list.at(i)->setDisabled(false);
|
||||
}
|
||||
for (i = enable_stages; i < TriggerStages; i++) {
|
||||
stage_tabWidget->setTabEnabled(i, false);
|
||||
// _mu_label_list.at(i)->setVisible(false);
|
||||
// _logic_comboBox_list.at(i)->setVisible(false);
|
||||
|
||||
// _value0_lineEdit_list.at(i)->setVisible(false);
|
||||
// _count0_spinBox_list.at(i)->setVisible(false);
|
||||
// _inv0_comboBox_list.at(i)->setVisible(false);
|
||||
|
||||
// _value1_lineEdit_list.at(i)->setVisible(false);
|
||||
// _count1_spinBox_list.at(i)->setVisible(false);
|
||||
// _inv1_comboBox_list.at(i)->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::value_changed()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (_adv_tabWidget->currentIndex() == 0) {
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
_value0_lineEdit_list.at(i)->setText(_value0_lineEdit_list.at(i)->text().toUpper());
|
||||
while(_value0_lineEdit_list.at(i)->text().length() < TriggerProbes)
|
||||
_value0_lineEdit_list.at(i)->setText("X" + _value0_lineEdit_list.at(i)->text());
|
||||
|
||||
_value1_lineEdit_list.at(i)->setText(_value1_lineEdit_list.at(i)->text().toUpper());
|
||||
while(_value1_lineEdit_list.at(i)->text().length() < TriggerProbes)
|
||||
_value1_lineEdit_list.at(i)->setText("X" + _value1_lineEdit_list.at(i)->text());
|
||||
|
||||
ds_trigger_stage_set_value(i, TriggerProbes,
|
||||
_value0_lineEdit_list.at(i)->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(i)->text().toLocal8Bit().data());
|
||||
}
|
||||
} else if(_adv_tabWidget->currentIndex() == 1){
|
||||
_serial_start_lineEdit->setText(_serial_start_lineEdit->text().toUpper());
|
||||
ds_trigger_stage_set_value(0, TriggerProbes,
|
||||
_serial_start_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(0)->text().toLocal8Bit().data());
|
||||
_serial_stop_lineEdit->setText(_serial_stop_lineEdit->text().toUpper());
|
||||
ds_trigger_stage_set_value(1, TriggerProbes,
|
||||
_serial_stop_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(1)->text().toLocal8Bit().data());
|
||||
_serial_edge_lineEdit->setText(_serial_edge_lineEdit->text().toUpper());
|
||||
ds_trigger_stage_set_value(2, TriggerProbes,
|
||||
_serial_edge_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(2)->text().toLocal8Bit().data());
|
||||
//_serial_data_comboBox
|
||||
const int data_channel = _serial_data_comboBox->currentText().toInt();
|
||||
char channel[31];
|
||||
for(i = 0; i < 31; i++){
|
||||
if (i == (30 - 2*data_channel))
|
||||
channel[i] = '1';
|
||||
else if (i%2 == 0)
|
||||
channel[i] = '0';
|
||||
else
|
||||
channel[i] = ' ';
|
||||
}
|
||||
ds_trigger_stage_set_value(3, TriggerProbes,
|
||||
channel,
|
||||
_value1_lineEdit_list.at(3)->text().toLocal8Bit().data());
|
||||
_serial_value_lineEdit->setText(_serial_value_lineEdit->text().toUpper());
|
||||
ds_trigger_stage_set_value(4, TriggerProbes,
|
||||
_serial_value_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(4)->text().toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::serial_channel_changed(int index)
|
||||
{
|
||||
(void)index;
|
||||
value_changed();
|
||||
}
|
||||
|
||||
void TriggerDock::logic_changed(int index)
|
||||
{
|
||||
(void)index;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_logic(i, TriggerProbes,
|
||||
_logic_comboBox_list.at(i)->currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::inv_changed(int index)
|
||||
{
|
||||
(void)index;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_inv(i, TriggerProbes,
|
||||
_inv0_comboBox_list.at(i)->currentIndex(),
|
||||
_inv1_comboBox_list.at(i)->currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::count_changed()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_count(i, TriggerProbes,
|
||||
_count0_spinBox_list.at(i)->value() - 1,
|
||||
_count1_spinBox_list.at(i)->value() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::pos_changed(int pos)
|
||||
{
|
||||
ds_trigger_set_pos(pos);
|
||||
QLineEdit* sc=dynamic_cast<QLineEdit*>(sender());
|
||||
if(sc != NULL)
|
||||
sc->setText(sc->text().toUpper());
|
||||
}
|
||||
|
||||
void TriggerDock::device_change()
|
||||
{
|
||||
uint64_t max_hd_depth;
|
||||
bool stream = false;
|
||||
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
uint8_t maxRange;
|
||||
uint64_t sample_limits;
|
||||
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_LOGIC_SAMPLELIMITS);
|
||||
if (gvar != NULL) {
|
||||
stream = g_variant_get_boolean(gvar);
|
||||
max_hd_depth = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
if (stream &&
|
||||
strcmp(_session.get_device()->dev_inst()->driver->name, "DSLogic") == 0) {
|
||||
const int maxRange = SR_MB(11)*100/_session.get_device()->get_sample_limit();
|
||||
position_spinBox->setRange(0, maxRange);
|
||||
position_slider->setRange(0, maxRange);
|
||||
simple_radioButton->setChecked(true);
|
||||
simple_trigger();
|
||||
} else {
|
||||
position_spinBox->setRange(0, 99);
|
||||
position_slider->setRange(0, 99);
|
||||
if (_session.get_device()->dev_inst()->mode == LOGIC) {
|
||||
sample_limits = _session.get_device()->get_sample_limit();
|
||||
if (max_hd_depth >= sample_limits)
|
||||
maxRange = 99;
|
||||
else
|
||||
maxRange = max_hd_depth*70 / sample_limits;
|
||||
position_spinBox->setRange(0, maxRange);
|
||||
position_slider->setRange(0, maxRange);
|
||||
|
||||
|
||||
|
||||
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
if (gvar != NULL) {
|
||||
stream = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
if (!strncmp(_session.get_device()->dev_inst()->driver->name, "virtual", 7) ||
|
||||
stream) {
|
||||
simple_radioButton->setChecked(true);
|
||||
simple_trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerDock::adv_tog(int index)
|
||||
bool TriggerDock::commit_trigger()
|
||||
{
|
||||
if(index == 0) {
|
||||
stages_label->setDisabled(false);
|
||||
stages_comboBox->setDisabled(false);
|
||||
ds_trigger_set_mode(ADV_TRIGGER);
|
||||
} else if (index == 1) {
|
||||
stages_label->setDisabled(true);
|
||||
stages_comboBox->setDisabled(true);
|
||||
ds_trigger_set_mode(SERIAL_TRIGGER);
|
||||
// trigger position update
|
||||
ds_trigger_set_pos(position_slider->value());
|
||||
|
||||
// trigger mode update
|
||||
if (simple_radioButton->isChecked()) {
|
||||
ds_trigger_set_mode(SIMPLE_TRIGGER);
|
||||
return 0;
|
||||
} else {
|
||||
ds_trigger_set_en(true);
|
||||
if (_adv_tabWidget->currentIndex() == 0)
|
||||
ds_trigger_set_mode(ADV_TRIGGER);
|
||||
else if (_adv_tabWidget->currentIndex() == 1)
|
||||
ds_trigger_set_mode(SERIAL_TRIGGER);
|
||||
|
||||
// trigger stage update
|
||||
ds_trigger_set_stage(stages_comboBox->currentText().toInt());
|
||||
|
||||
int i;
|
||||
// trigger value update
|
||||
if (_adv_tabWidget->currentIndex() == 0) {
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_value(i, TriggerProbes,
|
||||
_value0_lineEdit_list.at(i)->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(i)->text().toLocal8Bit().data());
|
||||
}
|
||||
} else if(_adv_tabWidget->currentIndex() == 1){
|
||||
ds_trigger_stage_set_value(0, TriggerProbes,
|
||||
_serial_start_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(0)->text().toLocal8Bit().data());
|
||||
ds_trigger_stage_set_value(1, TriggerProbes,
|
||||
_serial_stop_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(1)->text().toLocal8Bit().data());
|
||||
ds_trigger_stage_set_value(2, TriggerProbes,
|
||||
_serial_edge_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(2)->text().toLocal8Bit().data());
|
||||
//_serial_data_comboBox
|
||||
const int data_channel = _serial_data_comboBox->currentText().toInt();
|
||||
char channel[31];
|
||||
for(i = 0; i < 31; i++){
|
||||
if (i == (30 - 2*data_channel))
|
||||
channel[i] = '1';
|
||||
else if (i%2 == 0)
|
||||
channel[i] = '0';
|
||||
else
|
||||
channel[i] = ' ';
|
||||
}
|
||||
ds_trigger_stage_set_value(3, TriggerProbes,
|
||||
channel,
|
||||
_value1_lineEdit_list.at(3)->text().toLocal8Bit().data());
|
||||
ds_trigger_stage_set_value(4, TriggerProbes,
|
||||
_serial_value_lineEdit->text().toLocal8Bit().data(),
|
||||
_value1_lineEdit_list.at(4)->text().toLocal8Bit().data());
|
||||
}
|
||||
|
||||
// trigger logic update
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_logic(i, TriggerProbes,
|
||||
_logic_comboBox_list.at(i)->currentIndex());
|
||||
}
|
||||
|
||||
// trigger inv update
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_inv(i, TriggerProbes,
|
||||
_inv0_comboBox_list.at(i)->currentIndex(),
|
||||
_inv1_comboBox_list.at(i)->currentIndex());
|
||||
}
|
||||
|
||||
// trigger count update
|
||||
for (i = 0; i < stages_comboBox->currentText().toInt(); i++) {
|
||||
ds_trigger_stage_set_count(i, TriggerProbes,
|
||||
_count0_spinBox_list.at(i)->value() - 1,
|
||||
_count1_spinBox_list.at(i)->value() - 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
value_changed();
|
||||
logic_changed(0);
|
||||
inv_changed(0);
|
||||
count_changed();
|
||||
}
|
||||
|
||||
void TriggerDock::init()
|
||||
@@ -597,11 +518,6 @@ void TriggerDock::set_session(QJsonObject ses)
|
||||
_serial_edge_lineEdit->setText(ses["triggerClock"].toString());
|
||||
_serial_data_comboBox->setCurrentIndex(ses["triggerChannel"].toDouble());
|
||||
_serial_value_lineEdit->setText(ses["triggerData"].toString());
|
||||
|
||||
value_changed();
|
||||
logic_changed(0);
|
||||
inv_changed(0);
|
||||
count_changed();
|
||||
}
|
||||
|
||||
} // namespace dock
|
||||
|
||||
@@ -61,30 +61,28 @@ public:
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
void device_change();
|
||||
|
||||
void init();
|
||||
|
||||
QJsonObject get_session();
|
||||
void set_session(QJsonObject ses);
|
||||
|
||||
/*
|
||||
* commit trigger setting
|
||||
* return 0: simple trigger
|
||||
* 1: advanced trigger
|
||||
*/
|
||||
bool commit_trigger();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void simple_trigger();
|
||||
void adv_trigger();
|
||||
void trigger_stages_changed(int index);
|
||||
void widget_enable();
|
||||
void widget_enable(int index);
|
||||
|
||||
void value_changed();
|
||||
void logic_changed(int index);
|
||||
void count_changed();
|
||||
void inv_changed(int index);
|
||||
|
||||
void pos_changed(int pos);
|
||||
|
||||
void adv_tog(int index);
|
||||
void serial_channel_changed(int index);
|
||||
void device_change();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
#include "view/trace.h"
|
||||
#include "view/signal.h"
|
||||
#include "view/dsosignal.h"
|
||||
#include "view/logicsignal.h"
|
||||
|
||||
/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
|
||||
#define __STDC_FORMAT_MACROS
|
||||
@@ -192,6 +193,8 @@ void MainWindow::setup_ui()
|
||||
SLOT(instant_stop()));
|
||||
connect(_sampling_bar, SIGNAL(update_scale()), _view,
|
||||
SLOT(update_scale()), Qt::DirectConnection);
|
||||
connect(_sampling_bar, SIGNAL(sample_count_changed()), _trigger_widget,
|
||||
SLOT(device_change()));
|
||||
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(quint64)), _view,
|
||||
SLOT(set_trig_pos(quint64)));
|
||||
|
||||
@@ -284,6 +287,7 @@ void MainWindow::update_device_list()
|
||||
{
|
||||
assert(_sampling_bar);
|
||||
|
||||
_session.stop_capture();
|
||||
_view->show_trig_cursor(false);
|
||||
_trigger_widget->device_change();
|
||||
#ifdef ENABLE_DECODE
|
||||
@@ -315,8 +319,7 @@ void MainWindow::update_device_list()
|
||||
errorMessage, infoMessage));
|
||||
}
|
||||
|
||||
if (strcmp(selected_device->dev_inst()->driver->name, "demo") != 0 &&
|
||||
strcmp(selected_device->dev_inst()->driver->name, "virtual-session") != 0) {
|
||||
if (strncmp(selected_device->dev_inst()->driver->name, "virtual", 7)) {
|
||||
_logo_bar->dsl_connected(true);
|
||||
QString ses_name = config_path +
|
||||
QString::fromUtf8(selected_device->dev_inst()->driver->name) +
|
||||
@@ -411,6 +414,7 @@ void MainWindow::run_stop()
|
||||
case SigSession::Stopped:
|
||||
_view->show_trig_cursor(false);
|
||||
_view->update_sample(false);
|
||||
commit_trigger(false);
|
||||
_session.start_capture(false,
|
||||
boost::bind(&MainWindow::session_error, this,
|
||||
QString("Capture failed"), _1));
|
||||
@@ -434,6 +438,7 @@ void MainWindow::instant_stop()
|
||||
case SigSession::Stopped:
|
||||
_view->show_trig_cursor(false);
|
||||
_view->update_sample(true);
|
||||
commit_trigger(true);
|
||||
_session.start_capture(true,
|
||||
boost::bind(&MainWindow::session_error, this,
|
||||
QString("Capture failed"), _1));
|
||||
@@ -483,6 +488,25 @@ void MainWindow::capture_state_changed(int state)
|
||||
_sampling_bar->enable_toggle(state != SigSession::Running);
|
||||
_trig_bar->enable_toggle(state != SigSession::Running);
|
||||
_measure_dock->widget()->setEnabled(state != SigSession::Running);
|
||||
if (_session.get_device()->dev_inst()->mode == LOGIC &&
|
||||
state == SigSession::Stopped) {
|
||||
GVariant *gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_RLE);
|
||||
if (gvar != NULL) {
|
||||
bool rle = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
if (rle) {
|
||||
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_ACTUAL_SAMPLES);
|
||||
if (gvar != NULL) {
|
||||
uint64_t actual_samples = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
if (actual_samples != _session.get_device()->get_sample_limit()) {
|
||||
show_session_error(tr("RLE Mode Warning"),
|
||||
tr("Hardware buffer is full!\nActually received samples is less than setted sample depth!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef TEST_MODE
|
||||
if (state == SigSession::Stopped) {
|
||||
test_timer.start(100);
|
||||
@@ -498,7 +522,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
QString driver_name = _session.get_device()->dev_inst()->driver->name;
|
||||
QString mode_name = QString::number(_session.get_device()->dev_inst()->mode);
|
||||
QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + ".dsc";
|
||||
if (!file_name.isEmpty())
|
||||
if (strncmp(driver_name.toLocal8Bit(), "virtual", 7) &&
|
||||
!file_name.isEmpty())
|
||||
store_session(file_name);
|
||||
}
|
||||
event->accept();
|
||||
@@ -525,6 +550,26 @@ void MainWindow::on_trigger(bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::commit_trigger(bool instant)
|
||||
{
|
||||
ds_trigger_init();
|
||||
|
||||
if (_session.get_device()->dev_inst()->mode != LOGIC ||
|
||||
instant)
|
||||
return;
|
||||
|
||||
if (!_trigger_widget->commit_trigger()) {
|
||||
/* simple trigger check trigger_enable */
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals())
|
||||
{
|
||||
assert(s);
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s))
|
||||
logicSig->commit_trig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_measure(bool visible)
|
||||
{
|
||||
_measure_dock->setVisible(visible);
|
||||
@@ -632,7 +677,6 @@ bool MainWindow::load_session(QString name)
|
||||
bool isEnabled = false;
|
||||
foreach (const QJsonValue &value, sessionObj["channel"].toArray()) {
|
||||
QJsonObject obj = value.toObject();
|
||||
qDebug("obj.index = %d", obj["index"].toDouble());
|
||||
if ((probe->index == obj["index"].toDouble()) &&
|
||||
(probe->type == obj["type"].toDouble())) {
|
||||
isEnabled = true;
|
||||
@@ -659,13 +703,16 @@ bool MainWindow::load_session(QString name)
|
||||
if ((s->get_index() == obj["index"].toDouble()) &&
|
||||
(s->get_type() == obj["type"].toDouble())) {
|
||||
s->set_colour(QColor(obj["colour"].toString()));
|
||||
s->set_trig(obj["strigger"].toDouble());
|
||||
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
|
||||
logicSig->set_trig(obj["strigger"].toDouble());
|
||||
}
|
||||
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
dsoSig->update_hDial();
|
||||
//dsoSig->update_vDial();
|
||||
dsoSig->load_settings();
|
||||
dsoSig->set_zeroRate(obj["zeroPos"].toDouble());
|
||||
dsoSig->set_enable(obj["enabled"].toBool());
|
||||
dsoSig->set_trigRate(obj["trigValue"].toDouble());
|
||||
}
|
||||
break;
|
||||
@@ -736,11 +783,16 @@ bool MainWindow::store_session(QString name)
|
||||
s_obj["enabled"] = s->enabled();
|
||||
s_obj["name"] = s->get_name();
|
||||
s_obj["colour"] = QJsonValue::fromVariant(s->get_colour());
|
||||
s_obj["strigger"] = s->get_trig();
|
||||
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
|
||||
s_obj["strigger"] = logicSig->get_trig();
|
||||
}
|
||||
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
s_obj["vdiv"] = QJsonValue::fromVariant(dsoSig->get_vDialValue());
|
||||
s_obj["vfactor"] = QJsonValue::fromVariant(dsoSig->get_factor());
|
||||
s_obj["vdiv"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_vDialValue()));
|
||||
s_obj["vfactor"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_factor()));
|
||||
s_obj["coupling"] = dsoSig->get_acCoupling();
|
||||
s_obj["trigValue"] = dsoSig->get_trigRate();
|
||||
s_obj["zeroPos"] = dsoSig->get_zeroRate();
|
||||
|
||||
@@ -112,6 +112,8 @@ private slots:
|
||||
|
||||
void on_trigger(bool visible);
|
||||
|
||||
void commit_trigger(bool instant);
|
||||
|
||||
void on_measure(bool visible);
|
||||
|
||||
void on_search(bool visible);
|
||||
|
||||
@@ -82,6 +82,8 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
|
||||
case SR_CONF_BUFFERSIZE:
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
case SR_CONF_FILTER:
|
||||
case SR_CONF_MAX_HEIGHT:
|
||||
case SR_CONF_MAX_HEIGHT_VALUE:
|
||||
case SR_CONF_COUPLING:
|
||||
case SR_CONF_EN_CH:
|
||||
case SR_CONF_OPERATION_MODE:
|
||||
@@ -91,7 +93,7 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
|
||||
case SR_CONF_TEST:
|
||||
case SR_CONF_STATUS:
|
||||
case SR_CONF_FACTOR:
|
||||
bind_enum(name, key, gvar_list);
|
||||
bind_enum(name, key, gvar_list);
|
||||
break;
|
||||
|
||||
case SR_CONF_VTH:
|
||||
@@ -110,11 +112,11 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
|
||||
break;
|
||||
|
||||
case SR_CONF_TIMEBASE:
|
||||
bind_enum(name, key, gvar_list, print_timebase);
|
||||
bind_enum(name, key, gvar_list, print_timebase);
|
||||
break;
|
||||
|
||||
case SR_CONF_VDIV:
|
||||
bind_enum(name, key, gvar_list, print_vdiv);
|
||||
bind_enum(name, key, gvar_list, print_vdiv);
|
||||
break;
|
||||
default:
|
||||
gvar_list = NULL;
|
||||
@@ -153,7 +155,7 @@ void DeviceOptions::bind_bool(const QString &name, int key)
|
||||
}
|
||||
|
||||
void DeviceOptions::bind_enum(const QString &name, int key,
|
||||
GVariant *const gvar_list, boost::function<QString (GVariant*)> printer)
|
||||
GVariant *const gvar_list, boost::function<QString (GVariant*)> printer)
|
||||
{
|
||||
GVariant *gvar;
|
||||
GVariantIter iter;
|
||||
@@ -166,7 +168,7 @@ void DeviceOptions::bind_enum(const QString &name, int key,
|
||||
values.push_back(make_pair(gvar, printer(gvar)));
|
||||
|
||||
_properties.push_back(boost::shared_ptr<Property>(
|
||||
new Enum(name, values,
|
||||
new Enum(name, values,
|
||||
bind(config_getter, _sdi, key),
|
||||
bind(config_setter, _sdi, key, _1))));
|
||||
}
|
||||
@@ -235,7 +237,7 @@ void DeviceOptions::bind_samplerate(const QString &name,
|
||||
else if ((gvar_list_samplerates = g_variant_lookup_value(gvar_list,
|
||||
"samplerates", G_VARIANT_TYPE("at"))))
|
||||
{
|
||||
bind_enum(name, SR_CONF_SAMPLERATE,
|
||||
bind_enum(name, SR_CONF_SAMPLERATE,
|
||||
gvar_list_samplerates, print_samplerate);
|
||||
g_variant_unref(gvar_list_samplerates);
|
||||
}
|
||||
|
||||
@@ -32,20 +32,20 @@
|
||||
using boost::optional;
|
||||
using namespace std;
|
||||
|
||||
#define INT8_MIN (-0x7f - 1)
|
||||
#define INT16_MIN (-0x7fff - 1)
|
||||
#define INT32_MIN (-0x7fffffff - 1)
|
||||
#define INT64_MIN (-0x7fffffffffffffff - 1)
|
||||
|
||||
#define INT8_MAX 0x7f
|
||||
#define INT16_MAX 0x7fff
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#define INT64_MAX 0x7fffffffffffffff
|
||||
|
||||
#define UINT8_MAX 0xff
|
||||
#define UINT16_MAX 0xffff
|
||||
#define UINT32_MAX 0xffffffff
|
||||
#define UINT64_MAX 0xffffffffffffffff
|
||||
//#define INT8_MIN (-0x7f - 1)
|
||||
//#define INT16_MIN (-0x7fff - 1)
|
||||
//#define INT32_MIN (-0x7fffffff - 1)
|
||||
//#define INT64_MIN (-0x7fffffffffffffff - 1)
|
||||
//
|
||||
//#define INT8_MAX 0x7f
|
||||
//#define INT16_MAX 0x7fff
|
||||
//#define INT32_MAX 0x7fffffff
|
||||
//#define INT64_MAX 0x7fffffffffffffff
|
||||
//
|
||||
//#define UINT8_MAX 0xff
|
||||
//#define UINT16_MAX 0xffff
|
||||
//#define UINT32_MAX 0xffffffff
|
||||
//#define UINT64_MAX 0xffffffffffffffff
|
||||
|
||||
namespace pv {
|
||||
namespace prop {
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace prop {
|
||||
Property::Property(QString name, Getter getter, Setter setter) :
|
||||
_getter(getter),
|
||||
_setter(setter),
|
||||
_name(name)
|
||||
_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ public:
|
||||
typedef boost::function<void (GVariant*)> Setter;
|
||||
|
||||
protected:
|
||||
Property(QString name, Getter getter, Setter setter);
|
||||
Property(QString name, Getter getter, Setter setter);
|
||||
|
||||
public:
|
||||
const QString& name() const;
|
||||
const QString& name() const;
|
||||
|
||||
virtual QWidget* get_widget(QWidget *parent,
|
||||
bool auto_commit = false) = 0;
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
const Setter _setter;
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
QString _name;
|
||||
};
|
||||
|
||||
} // prop
|
||||
|
||||
@@ -64,7 +64,7 @@ void String::commit()
|
||||
if (!_line_edit)
|
||||
return;
|
||||
|
||||
QByteArray ba = _line_edit->text().toLocal8Bit();
|
||||
QByteArray ba = _line_edit->text().toUtf8();
|
||||
_setter(g_variant_new_string(ba.data()));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,9 +92,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
|
||||
_session = this;
|
||||
_hot_attach = false;
|
||||
_hot_detach = false;
|
||||
_adv_trigger = false;
|
||||
_group_cnt = 0;
|
||||
ds_trigger_init();
|
||||
register_hotplug_callback();
|
||||
_view_timer.stop();
|
||||
_view_timer.setSingleShot(true);
|
||||
@@ -177,19 +175,45 @@ void SigSession::set_file(QString name) throw(QString)
|
||||
}
|
||||
}
|
||||
|
||||
void SigSession::save_file(const QString name){
|
||||
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
|
||||
_logic_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return;
|
||||
|
||||
const boost::shared_ptr<pv::data::LogicSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
void SigSession::save_file(const QString name, int type){
|
||||
unsigned char* data;
|
||||
int unit_size;
|
||||
uint64_t sample_count;
|
||||
if (type == ANALOG) {
|
||||
const deque< boost::shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
|
||||
_analog_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return;
|
||||
const boost::shared_ptr<pv::data::AnalogSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
data = (unsigned char*)snapshot->get_data();
|
||||
unit_size = snapshot->unit_size();
|
||||
sample_count = snapshot->get_sample_count();
|
||||
} else if (type == DSO) {
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_dso_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return;
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
data = (unsigned char*)snapshot->get_data();
|
||||
// snapshot->unit_size() is not valid for dso, replaced by enabled channel number
|
||||
unit_size = get_ch_num(SR_CHANNEL_DSO);
|
||||
sample_count = snapshot->get_sample_count();
|
||||
} else {
|
||||
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
|
||||
_logic_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return;
|
||||
const boost::shared_ptr<pv::data::LogicSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
data = (unsigned char*)snapshot->get_data();
|
||||
unit_size = snapshot->unit_size();
|
||||
sample_count = snapshot->get_sample_count();
|
||||
}
|
||||
|
||||
sr_session_save(name.toLocal8Bit().data(), _dev_inst->dev_inst(),
|
||||
(unsigned char*)snapshot->get_data(),
|
||||
snapshot->unit_size(),
|
||||
snapshot->get_sample_count());
|
||||
data, unit_size, sample_count);
|
||||
}
|
||||
|
||||
QList<QString> SigSession::getSuportedExportFormats(){
|
||||
@@ -205,7 +229,7 @@ QList<QString> SigSession::getSuportedExportFormats(){
|
||||
format.append((*supportedModules)->id);
|
||||
format.append(")");
|
||||
list.append(format);
|
||||
*supportedModules++;
|
||||
supportedModules++;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -245,7 +269,7 @@ void SigSession::export_file(const QString name, QWidget* parent, const QString
|
||||
outModule = *supportedModules;
|
||||
break;
|
||||
}
|
||||
*supportedModules++;
|
||||
supportedModules++;
|
||||
}
|
||||
if(outModule == NULL)
|
||||
return;
|
||||
@@ -283,8 +307,8 @@ void SigSession::export_file(const QString name, QWidget* parent, const QString
|
||||
unsigned char* datat = (unsigned char*)snapshot->get_data();
|
||||
unsigned int numsamples = snapshot->get_sample_count()*snapshot->unit_size();
|
||||
GString *data_out;
|
||||
int usize = 8192;
|
||||
int size = usize;
|
||||
unsigned int usize = 8192;
|
||||
unsigned int size = usize;
|
||||
struct sr_datafeed_logic lp;
|
||||
struct sr_datafeed_packet p;
|
||||
for(uint64_t i = 0; i < numsamples; i+=usize){
|
||||
@@ -311,8 +335,8 @@ void SigSession::export_file(const QString name, QWidget* parent, const QString
|
||||
unsigned char* datat = (unsigned char*)snapshot->get_data();
|
||||
unsigned int numsamples = snapshot->get_sample_count();
|
||||
GString *data_out;
|
||||
int usize = 8192;
|
||||
int size = usize;
|
||||
unsigned int usize = 8192;
|
||||
unsigned int size = usize;
|
||||
struct sr_datafeed_dso dp;
|
||||
struct sr_datafeed_packet p;
|
||||
for(uint64_t i = 0; i < numsamples; i+=usize){
|
||||
@@ -365,8 +389,8 @@ void SigSession::set_default_device(boost::function<void (const QString)> error_
|
||||
// Try and find the DreamSourceLab device and select that by default
|
||||
BOOST_FOREACH (boost::shared_ptr<pv::device::DevInst> dev, devices)
|
||||
if (dev->dev_inst() &&
|
||||
strcmp(dev->dev_inst()->driver->name,
|
||||
"demo") != 0) {
|
||||
strncmp(dev->dev_inst()->driver->name,
|
||||
"virtual", 7) != 0) {
|
||||
default_device = dev;
|
||||
break;
|
||||
}
|
||||
@@ -423,7 +447,10 @@ void SigSession::start_capture(bool instant,
|
||||
}
|
||||
|
||||
// update setting
|
||||
_instant = instant;
|
||||
if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session"))
|
||||
_instant = instant;
|
||||
else
|
||||
_instant = true;
|
||||
if (~_instant)
|
||||
_view_timer.blockSignals(false);
|
||||
|
||||
@@ -436,6 +463,7 @@ void SigSession::start_capture(bool instant,
|
||||
|
||||
void SigSession::stop_capture()
|
||||
{
|
||||
_instant = false;
|
||||
if (get_capture_state() != Running)
|
||||
return;
|
||||
sr_session_stop();
|
||||
@@ -467,6 +495,7 @@ set< boost::shared_ptr<data::SignalData> > SigSession::get_data() const
|
||||
assert(sig);
|
||||
data.insert(sig->data());
|
||||
}
|
||||
data.insert(_group_data);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -532,25 +561,6 @@ void SigSession::sample_thread_proc(boost::shared_ptr<device::DevInst> dev_inst,
|
||||
assert(dev_inst->dev_inst());
|
||||
assert(error_handler);
|
||||
|
||||
if (_instant) {
|
||||
/* disable trigger under instant mode */
|
||||
ds_trigger_set_en(false);
|
||||
} else if (!_adv_trigger) {
|
||||
/* simple trigger check trigger_enable */
|
||||
ds_trigger_set_en(false);
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _signals)
|
||||
{
|
||||
assert(s);
|
||||
if (s->get_trig() != 0) {
|
||||
ds_trigger_set_en(true);
|
||||
s->set_trig(s->get_trig());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* advanced trigger check trigger_enable */
|
||||
ds_trigger_set_en(true);
|
||||
}
|
||||
|
||||
try {
|
||||
dev_inst->start();
|
||||
} catch(const QString e) {
|
||||
@@ -623,16 +633,18 @@ void SigSession::add_group()
|
||||
_group_traces.push_back(signal);
|
||||
_group_cnt++;
|
||||
|
||||
if (_capture_state == Stopped) {
|
||||
if (!_cur_group_snapshot)
|
||||
{
|
||||
const deque< boost::shared_ptr<data::LogicSnapshot> > &snapshots =
|
||||
_logic_data->get_snapshots();
|
||||
if (!snapshots.empty()) {
|
||||
//if (!_cur_group_snapshot)
|
||||
//{
|
||||
// Create a new data snapshot
|
||||
_cur_group_snapshot = boost::shared_ptr<data::GroupSnapshot>(
|
||||
new data::GroupSnapshot(_logic_data->get_snapshots().front(), signal->get_index_list()));
|
||||
new data::GroupSnapshot(snapshots.front(), signal->get_index_list()));
|
||||
//_cur_group_snapshot->append_payload();
|
||||
_group_data->push_snapshot(_cur_group_snapshot);
|
||||
_cur_group_snapshot.reset();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
signals_changed();
|
||||
@@ -719,10 +731,6 @@ void SigSession::init_signals()
|
||||
if (logic_probe_count != 0) {
|
||||
_logic_data.reset(new data::Logic());
|
||||
assert(_logic_data);
|
||||
|
||||
_group_data.reset(new data::Group());
|
||||
assert(_group_data);
|
||||
_group_cnt = 0;
|
||||
}
|
||||
|
||||
if (dso_probe_count != 0) {
|
||||
@@ -734,10 +742,17 @@ void SigSession::init_signals()
|
||||
_analog_data.reset(new data::Analog());
|
||||
assert(_analog_data);
|
||||
}
|
||||
|
||||
_group_data.reset(new data::Group());
|
||||
assert(_group_data);
|
||||
_group_cnt = 0;
|
||||
}
|
||||
|
||||
// Make the logic probe list
|
||||
{
|
||||
_group_traces.clear();
|
||||
vector< boost::shared_ptr<view::GroupSignal> >().swap(_group_traces);
|
||||
|
||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
||||
const sr_channel *const probe =
|
||||
(const sr_channel *)l->data;
|
||||
@@ -793,12 +808,22 @@ void SigSession::reload()
|
||||
signal.reset();
|
||||
switch(probe->type) {
|
||||
case SR_CHANNEL_LOGIC:
|
||||
if (probe->enabled && probe->index < _signals.size())
|
||||
signal = boost::shared_ptr<view::Signal>(
|
||||
new view::LogicSignal(*_signals[probe->index].get(), _logic_data, probe));
|
||||
else if (probe->enabled)
|
||||
signal = boost::shared_ptr<view::Signal>(
|
||||
new view::LogicSignal(_dev_inst, _logic_data, probe));
|
||||
if (probe->enabled) {
|
||||
std::vector< boost::shared_ptr<view::Signal> >::iterator i = _signals.begin();
|
||||
while (i != _signals.end()) {
|
||||
if ((*i)->get_index() == probe->index) {
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(*i))
|
||||
signal = boost::shared_ptr<view::Signal>(
|
||||
new view::LogicSignal(logicSig, _logic_data, probe));
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!signal.get())
|
||||
signal = boost::shared_ptr<view::Signal>(
|
||||
new view::LogicSignal(_dev_inst, _logic_data, probe));
|
||||
}
|
||||
break;
|
||||
|
||||
case SR_CHANNEL_DSO:
|
||||
@@ -838,8 +863,10 @@ void SigSession::refresh(int holdtime)
|
||||
_analog_data->clear();
|
||||
_cur_analog_snapshot.reset();
|
||||
}
|
||||
_data_lock = true;
|
||||
_refresh_timer.start(holdtime);
|
||||
if (strncmp(_dev_inst->dev_inst()->driver->name, "virtual", 7)) {
|
||||
_data_lock = true;
|
||||
_refresh_timer.start(holdtime);
|
||||
}
|
||||
data_updated();
|
||||
}
|
||||
|
||||
@@ -1056,13 +1083,16 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
|
||||
{
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(_data_mutex);
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::GroupSignal> g, _group_traces)
|
||||
{
|
||||
assert(g);
|
||||
if (_cur_logic_snapshot) {
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::GroupSignal> g, _group_traces)
|
||||
{
|
||||
assert(g);
|
||||
|
||||
_cur_group_snapshot = boost::shared_ptr<data::GroupSnapshot>(
|
||||
new data::GroupSnapshot(_logic_data->get_snapshots().front(), g->get_index_list()));
|
||||
_group_data->push_snapshot(_cur_group_snapshot);
|
||||
_cur_group_snapshot = boost::shared_ptr<data::GroupSnapshot>(
|
||||
new data::GroupSnapshot(_logic_data->get_snapshots().front(), g->get_index_list()));
|
||||
_group_data->push_snapshot(_cur_group_snapshot);
|
||||
_cur_group_snapshot.reset();
|
||||
}
|
||||
}
|
||||
_cur_logic_snapshot.reset();
|
||||
_cur_dso_snapshot.reset();
|
||||
@@ -1186,15 +1216,6 @@ void SigSession::stop_hotplug_proc()
|
||||
_hotplug.reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* Tigger
|
||||
*/
|
||||
void SigSession::set_adv_trigger(bool adv_trigger)
|
||||
{
|
||||
_adv_trigger = adv_trigger;
|
||||
}
|
||||
|
||||
|
||||
uint16_t SigSession::get_ch_num(int type)
|
||||
{
|
||||
uint16_t num_channels = 0;
|
||||
|
||||
@@ -117,13 +117,11 @@ public:
|
||||
void set_file(QString name)
|
||||
throw(QString);
|
||||
|
||||
void save_file(const QString name);
|
||||
void save_file(const QString name, int type);
|
||||
|
||||
void set_default_device(boost::function<void (const QString)> error_handler);
|
||||
void export_file(const QString name, QWidget* parent, const QString ext);
|
||||
|
||||
void set_default_device();
|
||||
|
||||
void release_device(device::DevInst *dev_inst);
|
||||
|
||||
capture_state get_capture_state() const;
|
||||
@@ -171,8 +169,6 @@ public:
|
||||
void register_hotplug_callback();
|
||||
void deregister_hotplug_callback();
|
||||
|
||||
void set_adv_trigger(bool adv_trigger);
|
||||
|
||||
uint16_t get_ch_num(int type);
|
||||
|
||||
bool get_instant();
|
||||
@@ -251,15 +247,13 @@ private:
|
||||
boost::shared_ptr<data::GroupSnapshot> _cur_group_snapshot;
|
||||
int _group_cnt;
|
||||
|
||||
std::auto_ptr<boost::thread> _sampling_thread;
|
||||
std::unique_ptr<boost::thread> _sampling_thread;
|
||||
|
||||
libusb_hotplug_callback_handle _hotplug_handle;
|
||||
std::auto_ptr<boost::thread> _hotplug;
|
||||
std::unique_ptr<boost::thread> _hotplug;
|
||||
bool _hot_attach;
|
||||
bool _hot_detach;
|
||||
|
||||
bool _adv_trigger;
|
||||
|
||||
QTimer _view_timer;
|
||||
QTimer _refresh_timer;
|
||||
bool _data_lock;
|
||||
|
||||
@@ -150,8 +150,9 @@ void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
|
||||
uint64_t start_sample = 0;
|
||||
|
||||
/// TODO: Wrap this in a std::unique_ptr when we transition to C++11
|
||||
uint8_t *const data = new uint8_t[BlockSize];
|
||||
assert(data);
|
||||
uint8_t *data = NULL;
|
||||
//uint8_t *const data = new uint8_t[BlockSize];
|
||||
//assert(data);
|
||||
|
||||
const int unit_size = snapshot->unit_size();
|
||||
assert(unit_size != 0);
|
||||
@@ -170,7 +171,7 @@ void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
|
||||
|
||||
const uint64_t end_sample = min(
|
||||
start_sample + samples_per_block, _unit_count);
|
||||
snapshot->get_samples(data, start_sample, end_sample);
|
||||
data = snapshot->get_samples(start_sample, end_sample);
|
||||
|
||||
if(sr_session_append(_file_name.c_str(), data, unit_size,
|
||||
end_sample - start_sample) != SR_OK)
|
||||
@@ -189,7 +190,7 @@ void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
|
||||
|
||||
progress_updated();
|
||||
|
||||
delete[] data;
|
||||
//delete[] data;
|
||||
}
|
||||
|
||||
} // pv
|
||||
|
||||
@@ -200,22 +200,16 @@ void FileBar::on_actionSave_triggered()
|
||||
msg.setStandardButtons(QMessageBox::Ok);
|
||||
msg.setIcon(QMessageBox::Warning);
|
||||
msg.exec();
|
||||
} else if (_session.get_device()->dev_inst()->mode != LOGIC) {
|
||||
QMessageBox msg(this);
|
||||
msg.setText(tr("File Save"));
|
||||
msg.setInformativeText(tr("DSView currently only support saving logic data to file!"));
|
||||
msg.setStandardButtons(QMessageBox::Ok);
|
||||
msg.setIcon(QMessageBox::Warning);
|
||||
msg.exec();
|
||||
}else {
|
||||
} else {
|
||||
QString file_name = QFileDialog::getSaveFileName(
|
||||
this, tr("Save File"), "",
|
||||
tr("DSView Data (*.dsl)"));
|
||||
this, tr("Save File"), "",
|
||||
tr("DSView Data (*.dsl)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QFileInfo f(file_name);
|
||||
if(f.suffix().compare("dsl"))
|
||||
file_name.append(tr(".dsl"));
|
||||
_session.save_file(file_name);
|
||||
_session.save_file(file_name, _session.get_device()->dev_inst()->mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +222,12 @@ void SamplingBar::on_configure()
|
||||
|
||||
pv::dialogs::DeviceOptions dlg(this, dev_inst);
|
||||
ret = dlg.exec();
|
||||
if (ret == QDialog::Accepted)
|
||||
if (ret == QDialog::Accepted) {
|
||||
device_updated();
|
||||
update_sample_count_selector();
|
||||
update_sample_rate_selector();
|
||||
commit_sample_rate();
|
||||
}
|
||||
|
||||
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_ZERO);
|
||||
if (gvar != NULL) {
|
||||
@@ -289,12 +293,24 @@ void SamplingBar::set_record_length(uint64_t length)
|
||||
|
||||
void SamplingBar::update_record_length()
|
||||
{
|
||||
update_sample_count_selector_value();
|
||||
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()
|
||||
{
|
||||
update_sample_rate_selector_value();
|
||||
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)));
|
||||
}
|
||||
|
||||
void SamplingBar::set_sampling(bool sampling)
|
||||
@@ -415,9 +431,9 @@ void SamplingBar::update_sample_rate_selector()
|
||||
_updating_sample_rate = false;
|
||||
g_variant_unref(gvar_dict);
|
||||
|
||||
update_sample_rate_selector_value();
|
||||
connect(&_sample_rate, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplerate_sel(int)));
|
||||
update_sample_rate_selector_value();
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_rate_selector_value()
|
||||
@@ -438,7 +454,7 @@ void SamplingBar::update_sample_rate_selector_value()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
update_scale();
|
||||
_updating_sample_rate = false;
|
||||
}
|
||||
|
||||
@@ -478,12 +494,8 @@ void SamplingBar::commit_sample_rate()
|
||||
void SamplingBar::on_samplecount_sel(int index)
|
||||
{
|
||||
uint64_t sample_count = 0;
|
||||
uint64_t max_sample_count = 0;
|
||||
uint64_t last_sample_count = 0;
|
||||
bool stream_mode = false;
|
||||
bool buffer2stream = false;
|
||||
bool stream2buffer = false;
|
||||
|
||||
qDebug() << "index: " << index;
|
||||
if (index >= 0)
|
||||
sample_count = _sample_count.itemData(
|
||||
index).value<uint64_t>();
|
||||
@@ -492,58 +504,13 @@ void SamplingBar::on_samplecount_sel(int index)
|
||||
assert(_devInst);
|
||||
|
||||
if (strcmp(_devInst->dev_inst()->driver->name, "DSLogic") == 0 && _devInst->dev_inst()->mode != DSO) {
|
||||
GVariant* gvar = _devInst->get_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES);
|
||||
if (gvar != NULL) {
|
||||
last_sample_count = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
gvar = _devInst->get_config(NULL, NULL, SR_CONF_MAX_LOGIC_SAMPLELIMITS);
|
||||
if (gvar != NULL) {
|
||||
max_sample_count = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
gvar = _devInst->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
if (gvar != NULL) {
|
||||
stream_mode = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
if (((!stream_mode || (last_sample_count >= SR_GB(1))) && sample_count > max_sample_count) ||
|
||||
(sample_count >= SR_GB(1) && _devInst->get_sample_rate() <= SR_MHZ(10))) {
|
||||
stream_mode = sample_count > max_sample_count;
|
||||
buffer2stream = true;
|
||||
} else if (stream_mode && sample_count <= max_sample_count) {
|
||||
stream_mode = sample_count > max_sample_count;
|
||||
stream2buffer = true;
|
||||
}
|
||||
|
||||
// Set the sample count
|
||||
_devInst->set_config(NULL, NULL,
|
||||
SR_CONF_LIMIT_SAMPLES,
|
||||
g_variant_new_uint64(sample_count));
|
||||
|
||||
|
||||
|
||||
if (buffer2stream) {
|
||||
pv::dialogs::StreamOptions stream(this, _devInst, sample_count, stream_mode);
|
||||
stream.setFixedSize(300, 150);
|
||||
stream.exec();
|
||||
update_sample_rate_selector_value();
|
||||
update_sample_count_selector_value();
|
||||
_devInst->set_config(NULL, NULL,
|
||||
SR_CONF_STREAM,
|
||||
g_variant_new_boolean(true));
|
||||
} else if (stream2buffer) {
|
||||
QMessageBox msg(this);
|
||||
pv::dialogs::StreamOptions stream(this, _devInst, sample_count, stream_mode);
|
||||
stream.setFixedSize(300, 100);
|
||||
stream.exec();
|
||||
_devInst->set_config(NULL, NULL,
|
||||
SR_CONF_STREAM,
|
||||
g_variant_new_boolean(false));
|
||||
}
|
||||
|
||||
device_updated();
|
||||
sample_count_changed();
|
||||
update_scale();
|
||||
}
|
||||
}
|
||||
@@ -551,25 +518,23 @@ void SamplingBar::on_samplecount_sel(int index)
|
||||
void SamplingBar::on_samplerate_sel(int index)
|
||||
{
|
||||
uint64_t sample_rate = 0;
|
||||
//uint64_t last_sample_rate = 0;
|
||||
|
||||
if (index >= 0)
|
||||
sample_rate = _sample_rate.itemData(
|
||||
index).value<uint64_t>();
|
||||
|
||||
const sr_dev_inst* _sdi = get_selected_device()->dev_inst();
|
||||
assert(_sdi);
|
||||
boost::shared_ptr<pv::device::DevInst> _devInst = get_selected_device();
|
||||
assert(_devInst);
|
||||
|
||||
// Get last samplerate
|
||||
//last_sample_rate = get_selected_device()->get_sample_rate();
|
||||
|
||||
if (strcmp(_sdi->driver->name, "DSLogic") == 0 && _sdi->mode != DSO) {
|
||||
if (strcmp(_devInst->dev_inst()->driver->name, "DSLogic") == 0 && _devInst->dev_inst()->mode != DSO) {
|
||||
// Set the samplerate
|
||||
get_selected_device()->set_config(NULL, NULL,
|
||||
SR_CONF_SAMPLERATE,
|
||||
g_variant_new_uint64(sample_rate));
|
||||
update_sample_count_selector_value();
|
||||
device_updated();
|
||||
|
||||
update_scale();
|
||||
}
|
||||
}
|
||||
@@ -579,6 +544,8 @@ 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 max_sample_count = 0;
|
||||
|
||||
if (_updating_sample_count)
|
||||
return;
|
||||
@@ -601,6 +568,17 @@ void SamplingBar::update_sample_count_selector()
|
||||
return;
|
||||
}
|
||||
|
||||
GVariant* gvar = dev_inst->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||
if (gvar != NULL) {
|
||||
stream_mode = g_variant_get_boolean(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_RLE_SAMPLELIMITS);
|
||||
if (gvar != NULL) {
|
||||
max_sample_count = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
|
||||
if ((gvar_list = g_variant_lookup_value(gvar_dict,
|
||||
"samplecounts", G_VARIANT_TYPE("at"))))
|
||||
{
|
||||
@@ -611,8 +589,12 @@ void SamplingBar::update_sample_count_selector()
|
||||
for (unsigned int i = 0; i < num_elements; i++)
|
||||
{
|
||||
char *const s = sr_samplecount_string(elements[i]);
|
||||
_sample_count.addItem(QString(s),
|
||||
qVariantFromValue(elements[i]));
|
||||
if (!stream_mode && (elements[i] > max_sample_count))
|
||||
_sample_count.addItem(QString(s)+"(RLE)",
|
||||
qVariantFromValue(elements[i]));
|
||||
else
|
||||
_sample_count.addItem(QString(s),
|
||||
qVariantFromValue(elements[i]));
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
@@ -623,9 +605,9 @@ void SamplingBar::update_sample_count_selector()
|
||||
_updating_sample_count = false;
|
||||
g_variant_unref(gvar_dict);
|
||||
|
||||
update_sample_count_selector_value();
|
||||
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(on_samplecount_sel(int)));
|
||||
update_sample_count_selector_value();
|
||||
}
|
||||
|
||||
void SamplingBar::update_sample_count_selector_value()
|
||||
@@ -644,6 +626,8 @@ void SamplingBar::update_sample_count_selector_value()
|
||||
_sample_count.setCurrentIndex(i);
|
||||
|
||||
_updating_sample_count = false;
|
||||
sample_count_changed();
|
||||
update_scale();
|
||||
}
|
||||
|
||||
void SamplingBar::commit_sample_count()
|
||||
|
||||
@@ -96,6 +96,7 @@ signals:
|
||||
void device_selected();
|
||||
void device_updated();
|
||||
void update_scale();
|
||||
void sample_count_changed();
|
||||
|
||||
private:
|
||||
void update_sample_rate_selector();
|
||||
|
||||
@@ -137,8 +137,7 @@ void AnalogSignal::paint_trace(QPainter &p,
|
||||
//p.setPen(QPen(_colour, 2, Qt::SolidLine));
|
||||
|
||||
QPointF *points = new QPointF[sample_count];
|
||||
QPointF *point = points;
|
||||
|
||||
QPointF *point = points;
|
||||
for (int64_t sample = start; sample != end; sample++) {
|
||||
const float x = (sample / samples_per_pixel -
|
||||
pixels_offset) + left;
|
||||
@@ -147,7 +146,6 @@ void AnalogSignal::paint_trace(QPainter &p,
|
||||
}
|
||||
|
||||
p.drawPolyline(points, point - points);
|
||||
|
||||
//delete[] samples;
|
||||
delete[] points;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,8 @@ void Cursor::paint_fix_label(QPainter &p, const QRect &rect,
|
||||
|
||||
void Cursor::compute_text_size(QPainter &p, unsigned int prefix)
|
||||
{
|
||||
_text_size = p.boundingRect(QRectF(), 0,
|
||||
(void)prefix;
|
||||
_text_size = p.boundingRect(QRectF(), 0,
|
||||
Ruler::format_real_time(_index, _view.session().get_device()->get_sample_rate())).size();
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,18 @@ DecodeTrace::DecodeTrace(pv::SigSession &session,
|
||||
this, SLOT(on_show_hide_decoder(int)));
|
||||
}
|
||||
|
||||
DecodeTrace::~DecodeTrace()
|
||||
{
|
||||
if (_popup_form)
|
||||
delete _popup_form;
|
||||
if (_popup)
|
||||
delete _popup;
|
||||
_cur_row_headings.clear();
|
||||
_decoder_forms.clear();
|
||||
_probe_selectors.clear();
|
||||
_bindings.clear();
|
||||
}
|
||||
|
||||
bool DecodeTrace::enabled() const
|
||||
{
|
||||
return true;
|
||||
@@ -698,8 +710,10 @@ QComboBox* DecodeTrace::create_probe_selector(
|
||||
{
|
||||
selector->addItem(s->get_name(),
|
||||
qVariantFromValue((void*)s.get()));
|
||||
if ((*probe_iter).second == s)
|
||||
selector->setCurrentIndex(i + 1);
|
||||
if (probe_iter != dec->channels().end()) {
|
||||
if ((*probe_iter).second->get_index() == s->get_index())
|
||||
selector->setCurrentIndex(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,13 +823,12 @@ int DecodeTrace::rows_size()
|
||||
return _decoder_stack->cur_rows_size();
|
||||
}
|
||||
|
||||
void DecodeTrace::paint_type_options(QPainter &p, int right, bool hover, int action)
|
||||
void DecodeTrace::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
(void)hover;
|
||||
(void)action;
|
||||
(void)pt;
|
||||
|
||||
int y = get_y();
|
||||
const QRectF group_index_rect = get_rect("groupIndex", y, right);
|
||||
const QRectF group_index_rect = get_rect(CHNLREG, y, right);
|
||||
QString index_string;
|
||||
int last_index;
|
||||
p.setPen(Qt::transparent);
|
||||
@@ -837,5 +850,18 @@ void DecodeTrace::paint_type_options(QPainter &p, int right, bool hover, int act
|
||||
p.drawText(group_index_rect, Qt::AlignRight | Qt::AlignVCenter, index_string);
|
||||
}
|
||||
|
||||
QRectF DecodeTrace::get_rect(DecodeSetRegions type, int y, int right)
|
||||
{
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
|
||||
if (type == CHNLREG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * SquareNum, SquareWidth);
|
||||
else
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -71,6 +71,11 @@ private:
|
||||
const srd_channel *_pdch;
|
||||
};
|
||||
|
||||
enum DecodeSetRegions{
|
||||
NONEREG = -1,
|
||||
CHNLREG,
|
||||
};
|
||||
|
||||
private:
|
||||
static const QColor DecodeColours[4];
|
||||
static const QColor ErrorBgColour;
|
||||
@@ -89,6 +94,7 @@ public:
|
||||
DecodeTrace(pv::SigSession &session,
|
||||
boost::shared_ptr<pv::data::DecoderStack> decoder_stack,
|
||||
int index);
|
||||
~DecodeTrace();
|
||||
|
||||
bool enabled() const;
|
||||
|
||||
@@ -124,8 +130,10 @@ public:
|
||||
|
||||
int rows_size();
|
||||
|
||||
QRectF get_rect(DecodeSetRegions type, int y, int right);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, bool hover, int action);
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
private:
|
||||
void create_popup_form();
|
||||
|
||||
@@ -122,10 +122,10 @@ void DevMode::on_mode_change()
|
||||
i != _mode_button_list.end(); i++) {
|
||||
if ((*i).first.get() == button) {
|
||||
if (dev_inst->dev_inst()->mode != (*i).second->mode) {
|
||||
_view.session().stop_capture();
|
||||
dev_inst->set_config(NULL, NULL,
|
||||
SR_CONF_DEVICE_MODE,
|
||||
g_variant_new_int16((*i).second->mode));
|
||||
|
||||
mode_changed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ dslDial::~dslDial()
|
||||
{
|
||||
}
|
||||
|
||||
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor)
|
||||
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
|
||||
{
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setPen(dialColor);
|
||||
@@ -64,8 +64,22 @@ void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor)
|
||||
}
|
||||
QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
|
||||
QFontMetrics fm(p.font());
|
||||
p.drawText(QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height()), Qt::AlignCenter, pText);
|
||||
const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, 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 (inc)
|
||||
p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
|
||||
hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
|
||||
else
|
||||
p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
|
||||
hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
|
||||
}
|
||||
}
|
||||
|
||||
void dslDial::set_sel(uint64_t sel)
|
||||
|
||||
@@ -20,7 +20,7 @@ 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);
|
||||
void paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc);
|
||||
|
||||
// set/get current select
|
||||
void set_sel(uint64_t sel);
|
||||
|
||||
@@ -95,10 +95,10 @@ const QString DsoSignal::hDialUnit[DsoSignal::hDialUnitCount] = {
|
||||
};
|
||||
|
||||
const QColor DsoSignal::SignalColours[4] = {
|
||||
QColor(238, 178, 17, 200), // dsYellow
|
||||
QColor(0, 153, 37, 200), // dsGreen
|
||||
QColor(213, 15, 37, 200), // dsRed
|
||||
QColor(17, 133, 209, 200) // dsBlue
|
||||
QColor(238, 178, 17, 255), // dsYellow
|
||||
QColor(0, 153, 37, 255), // dsGreen
|
||||
QColor(213, 15, 37, 255), // dsRed
|
||||
QColor(17, 133, 209, 255) // dsBlue
|
||||
|
||||
};
|
||||
|
||||
@@ -120,14 +120,15 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
//_trig_vpos(probe->index * 0.5 + 0.25),
|
||||
//_zeroPos(probe->index * 0.5 + 0.25)
|
||||
_trig_vpos(0.5),
|
||||
_zeroPos(0.5),
|
||||
_zero_off(255/2.0),
|
||||
_autoV(false),
|
||||
_autoH(false),
|
||||
_hover_en(false),
|
||||
_hover_index(0),
|
||||
_hover_point(QPointF(0, 0)),
|
||||
_hover_value(0)
|
||||
_hover_value(0),
|
||||
_ms_gear_hover(false),
|
||||
_ms_show_hover(false),
|
||||
_ms_show(false)
|
||||
{
|
||||
QVector<uint64_t> vValue;
|
||||
QVector<QString> vUnit;
|
||||
@@ -148,34 +149,13 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
|
||||
_colour = SignalColours[probe->index % countof(SignalColours)];
|
||||
|
||||
// GVariant* gvar;
|
||||
for (int i = DSO_MS_BEGIN; i < DSO_MS_END; i++)
|
||||
_ms_en[i] = false;
|
||||
_ms_en[DSO_MS_FREQ] = true;
|
||||
_ms_en[DSO_MS_VMAX] = true;
|
||||
_ms_en[DSO_MS_VMIN] = true;
|
||||
|
||||
// gvar = dev_inst->get_config(probe, NULL, SR_CONF_VDIV);
|
||||
// if (gvar != NULL) {
|
||||
// _vDial->set_value(g_variant_get_uint64(gvar));
|
||||
// g_variant_unref(gvar);
|
||||
// } else {
|
||||
// qDebug() << "ERROR: config_get SR_CONF_VDIV failed.";
|
||||
// }
|
||||
|
||||
// gvar = dev_inst->get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
||||
// if (gvar != NULL) {
|
||||
// _hDial->set_value(g_variant_get_uint64(gvar));
|
||||
// g_variant_unref(gvar);
|
||||
// } else {
|
||||
// qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
// }
|
||||
|
||||
// gvar = dev_inst->get_config(probe, NULL, SR_CONF_COUPLING);
|
||||
// if (gvar != NULL) {
|
||||
// _acCoupling = g_variant_get_byte(gvar);
|
||||
// g_variant_unref(gvar);
|
||||
// } else {
|
||||
// qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
// }
|
||||
update_vDial();
|
||||
update_hDial();
|
||||
update_acCoupling();
|
||||
load_settings();
|
||||
}
|
||||
|
||||
DsoSignal::~DsoSignal()
|
||||
@@ -191,6 +171,14 @@ void DsoSignal::set_view(pv::view::View *view)
|
||||
{
|
||||
Trace::set_view(view);
|
||||
update_zeroPos();
|
||||
|
||||
const double ms_left = get_view_rect().right() - (MS_RectWidth + MS_RectMargin) * (get_index() + 1);
|
||||
const double ms_top = get_view_rect().top() + 5;
|
||||
for (int i = DSO_MS_BEGIN; i < DSO_MS_END; i++)
|
||||
_ms_rect[i] = QRect(ms_left, ms_top + MS_RectHeight * i, MS_RectWidth, MS_RectHeight);
|
||||
_ms_gear_rect = QRect(ms_left+MS_RectRad, ms_top+MS_RectRad, MS_IconSize, MS_IconSize);
|
||||
_ms_show_rect = QRect(ms_left+MS_RectWidth-MS_RectRad-MS_IconSize, ms_top+MS_RectRad, MS_IconSize, MS_IconSize);
|
||||
|
||||
}
|
||||
|
||||
void DsoSignal::set_scale(float scale)
|
||||
@@ -421,10 +409,10 @@ bool DsoSignal::go_hDialNext(bool setted)
|
||||
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()));
|
||||
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 {
|
||||
@@ -433,34 +421,24 @@ bool DsoSignal::go_hDialNext(bool setted)
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::update_vDial()
|
||||
bool DsoSignal::load_settings()
|
||||
{
|
||||
uint64_t vdiv;
|
||||
//uint64_t pre_vdiv = _vDial->get_value();
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VDIV);
|
||||
if (gvar != NULL) {
|
||||
vdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return false;
|
||||
}
|
||||
GVariant* gvar;
|
||||
|
||||
_vDial->set_value(vdiv);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_VDIV,
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
if (_view) {
|
||||
update_zeroPos();
|
||||
_view->set_need_update(true);
|
||||
_view->update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// -- enable
|
||||
//bool enable;
|
||||
//gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_EN_CH);
|
||||
//if (gvar != NULL) {
|
||||
// enable = g_variant_get_boolean(gvar);
|
||||
// g_variant_unref(gvar);
|
||||
//} else {
|
||||
// qDebug() << "ERROR: config_get SR_CONF_EN_CH failed.";
|
||||
// return false;
|
||||
//}
|
||||
|
||||
bool DsoSignal::update_hDial()
|
||||
{
|
||||
// -- hdiv
|
||||
uint64_t hdiv;
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TIMEBASE);
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TIMEBASE);
|
||||
if (gvar != NULL) {
|
||||
hdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
@@ -475,6 +453,60 @@ bool DsoSignal::update_hDial()
|
||||
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;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VDIV);
|
||||
if (gvar != NULL) {
|
||||
vdiv = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return false;
|
||||
}
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_FACTOR);
|
||||
if (gvar != NULL) {
|
||||
vfactor = g_variant_get_uint64(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_vDial->set_value(vdiv);
|
||||
_vDial->set_factor(vfactor);
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_VDIV,
|
||||
g_variant_new_uint64(_vDial->get_value()));
|
||||
|
||||
// -- coupling
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_COUPLING);
|
||||
if (gvar != NULL) {
|
||||
_acCoupling = g_variant_get_byte(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_COUPLING,
|
||||
g_variant_new_byte(_acCoupling));
|
||||
|
||||
// -- vpos
|
||||
double vpos;
|
||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_VPOS);
|
||||
if (gvar != NULL) {
|
||||
vpos = g_variant_get_double(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
return false;
|
||||
}
|
||||
_zeroPos = min(max((0.5 - vpos / (_vDial->get_value() * DS_CONF_DSO_VDIVS)), 0.0), 1.0);
|
||||
_zero_off = _zeroPos * 255;
|
||||
|
||||
if (_view) {
|
||||
_view->set_need_update(true);
|
||||
_view->update();
|
||||
}
|
||||
@@ -515,22 +547,6 @@ void DsoSignal::set_acCoupling(uint8_t coupling)
|
||||
}
|
||||
}
|
||||
|
||||
bool DsoSignal::update_acCoupling()
|
||||
{
|
||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_COUPLING);
|
||||
if (gvar != NULL) {
|
||||
_acCoupling = g_variant_get_byte(gvar);
|
||||
g_variant_unref(gvar);
|
||||
} else {
|
||||
qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
_dev_inst->set_config(_probe, NULL, SR_CONF_COUPLING,
|
||||
g_variant_new_byte(_acCoupling));
|
||||
return true;
|
||||
}
|
||||
|
||||
int DsoSignal::get_trig_vpos() const
|
||||
{
|
||||
return _trig_vpos * get_view_rect().height() + UpMargin;
|
||||
@@ -607,6 +623,7 @@ void DsoSignal::set_zeroPos(int pos)
|
||||
void DsoSignal::set_zeroRate(double rate)
|
||||
{
|
||||
_zeroPos = rate;
|
||||
_zero_off = rate * 255;
|
||||
update_zeroPos();
|
||||
}
|
||||
|
||||
@@ -648,6 +665,60 @@ uint64_t DsoSignal::get_factor()
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSignal::set_ms_show(bool show)
|
||||
{
|
||||
_ms_show = show;
|
||||
_view->set_need_update(true);
|
||||
}
|
||||
|
||||
bool DsoSignal::get_ms_show() const
|
||||
{
|
||||
return _ms_show;
|
||||
}
|
||||
|
||||
bool DsoSignal::get_ms_show_hover() const
|
||||
{
|
||||
return _ms_show_hover;
|
||||
}
|
||||
|
||||
bool DsoSignal::get_ms_gear_hover() const
|
||||
{
|
||||
return _ms_gear_hover;
|
||||
}
|
||||
|
||||
void DsoSignal::set_ms_en(int index, bool en)
|
||||
{
|
||||
assert(index > DSO_MS_BEGIN);
|
||||
assert(index < DSO_MS_END);
|
||||
|
||||
_ms_en[index] = en;
|
||||
}
|
||||
|
||||
bool DsoSignal::get_ms_en(int index) const
|
||||
{
|
||||
assert(index > DSO_MS_BEGIN);
|
||||
assert(index < DSO_MS_END);
|
||||
|
||||
return _ms_en[index];
|
||||
}
|
||||
|
||||
QString DsoSignal::get_ms_string(int index) const
|
||||
{
|
||||
assert(index > DSO_MS_BEGIN);
|
||||
assert(index < DSO_MS_END);
|
||||
|
||||
switch(index) {
|
||||
case DSO_MS_FREQ: return "Frequency";
|
||||
case DSO_MS_PERD: return "Period";
|
||||
case DSO_MS_VMAX: return "Vmax";
|
||||
case DSO_MS_VMIN: return "Vmin";
|
||||
case DSO_MS_VRMS: return "Vrms";
|
||||
case DSO_MS_VMEA: return "Vmean";
|
||||
case DSO_MS_VP2P: return "Vp-p";
|
||||
default: return "Error: Out of Bound";
|
||||
}
|
||||
}
|
||||
|
||||
void DsoSignal::update_zeroPos()
|
||||
{
|
||||
if (strcmp(_dev_inst->dev_inst()->driver->name, "DSCope") == 0) {
|
||||
@@ -742,6 +813,8 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
assert(scale > 0);
|
||||
const double offset = _view->offset();
|
||||
|
||||
paint_measure(p);
|
||||
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
@@ -779,8 +852,6 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right)
|
||||
start_sample, end_sample,
|
||||
pixels_offset, samples_per_pixel, number_channels);
|
||||
}
|
||||
|
||||
paint_measure(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,7 +927,6 @@ void DsoSignal::paint_trace(QPainter &p,
|
||||
QColor trace_colour = _colour;
|
||||
trace_colour.setAlpha(150);
|
||||
p.setPen(trace_colour);
|
||||
//p.setPen(QPen(_colour, 3, Qt::SolidLine));
|
||||
|
||||
QPointF *points = new QPointF[sample_count];
|
||||
QPointF *point = points;
|
||||
@@ -884,6 +954,8 @@ void DsoSignal::paint_trace(QPainter &p,
|
||||
}
|
||||
|
||||
p.drawPolyline(points, point - points);
|
||||
p.eraseRect(get_view_rect().right(), get_view_rect().top(),
|
||||
_view->viewport()->width() - get_view_rect().width(), get_view_rect().height());
|
||||
|
||||
//delete[] samples;
|
||||
delete[] points;
|
||||
@@ -952,30 +1024,31 @@ const std::vector< std::pair<uint64_t, bool> > DsoSignal::cur_edges() const
|
||||
|
||||
}
|
||||
|
||||
void DsoSignal::paint_type_options(QPainter &p, int right, bool hover, int action)
|
||||
void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
int y = get_y();
|
||||
const QRectF vDial_rect = get_rect("vDial", y, right);
|
||||
const QRectF x1_rect = get_rect("x1", y, right);
|
||||
const QRectF x10_rect = get_rect("x10", y, right);
|
||||
const QRectF x100_rect = get_rect("x100", y, right);
|
||||
const QRectF hDial_rect = get_rect("hDial", y, right);
|
||||
const QRectF acdc_rect = get_rect("acdc", y, right);
|
||||
const QRectF chEn_rect = get_rect("chEn", y, right);
|
||||
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);
|
||||
|
||||
QColor vDial_color = _vDialActive ? dsActive : dsDisable;
|
||||
QColor hDial_color = _hDialActive ? dsActive : dsDisable;
|
||||
_vDial->paint(p, vDial_rect, vDial_color);
|
||||
_hDial->paint(p, hDial_rect, hDial_color);
|
||||
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);
|
||||
|
||||
_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));
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush((hover && action == CHEN) ? _colour.darker() : _colour);
|
||||
p.setBrush(chEn_rect.contains(pt) ? _colour.darker() : _colour);
|
||||
p.drawRect(chEn_rect);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(chEn_rect, Qt::AlignCenter | Qt::AlignVCenter, enabled() ? tr("EN") : tr("DIS"));
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(enabled() ? ((hover && action == ACDC) ? _colour.darker() : _colour) : dsDisable);
|
||||
p.setBrush(enabled() ? (acdc_rect.contains(pt) ? _colour.darker() : _colour) : dsDisable);
|
||||
p.drawRect(acdc_rect);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, (_acCoupling == SR_GND_COUPLING) ? tr("GND") :
|
||||
@@ -994,19 +1067,189 @@ void DsoSignal::paint_type_options(QPainter &p, int right, bool hover, int actio
|
||||
}
|
||||
|
||||
p.setPen(Qt::white);
|
||||
p.setBrush((enabled() && (factor == 100)) ? ((hover && action == X100) ? _colour.darker() : _colour) : ((hover && action == X100) ? _colour.darker() : dsDisable));
|
||||
p.setBrush((enabled() && (factor == 100)) ? (x100_rect.contains(pt) ? _colour.darker() : _colour) : (x100_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x100_rect);
|
||||
p.drawText(x100_rect, Qt::AlignCenter | Qt::AlignVCenter, "x100");
|
||||
|
||||
p.setBrush((enabled() && (factor == 10)) ? ((hover && action == X10) ? _colour.darker() : _colour) : ((hover && action == X10) ? _colour.darker() : dsDisable));
|
||||
p.setBrush((enabled() && (factor == 10)) ? (x10_rect.contains(pt) ? _colour.darker() : _colour) : (x10_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x10_rect);
|
||||
p.drawText(x10_rect, Qt::AlignCenter | Qt::AlignVCenter, "x10");
|
||||
|
||||
p.setBrush((enabled() && (factor == 1)) ? ((hover && action == X1) ? _colour.darker() : _colour) : ((hover && action == X1) ? _colour.darker() : dsDisable));
|
||||
p.setBrush((enabled() && (factor == 1)) ? (x1_rect.contains(pt) ? _colour.darker() : _colour) : (x1_rect.contains(pt) ? _colour.darker() : dsDisable));
|
||||
p.drawRect(x1_rect);
|
||||
p.drawText(x1_rect, Qt::AlignCenter | Qt::AlignVCenter, "x1");
|
||||
}
|
||||
|
||||
bool DsoSignal::mouse_double_click(int right, const QPoint pt)
|
||||
{
|
||||
int y = get_zeroPos();
|
||||
const QRectF label_rect = Trace::get_rect("label", y, right);
|
||||
if (label_rect.contains(pt)) {
|
||||
this->auto_set();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
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 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);
|
||||
const QRectF x10_rect = get_rect(DSO_X10, y, right);
|
||||
const QRectF x100_rect = get_rect(DSO_X100, y, right);
|
||||
|
||||
if (chEn_rect.contains(pt)) {
|
||||
if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session") &&
|
||||
!_view->session().get_data_lock())
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(_dev_inst->dev_inst()->driver->name, "virtual-session") &&
|
||||
acdc_rect.contains(pt)) {
|
||||
if (strcmp(_view->session().get_device()->dev_inst()->driver->name, "DSLogic") == 0)
|
||||
set_acCoupling((get_acCoupling()+1)%2);
|
||||
else
|
||||
set_acCoupling((get_acCoupling()+1)%3);
|
||||
} else if (x1_rect.contains(pt)) {
|
||||
set_factor(1);
|
||||
} else if (x10_rect.contains(pt)) {
|
||||
set_factor(10);
|
||||
} else if (x100_rect.contains(pt)) {
|
||||
set_factor(100);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
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 > 1.0)
|
||||
go_vDialNext();
|
||||
else if (shift < -1.0)
|
||||
go_vDialPre();
|
||||
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 > 1.0) {
|
||||
dsoSig->go_hDialNext(setted);
|
||||
setted = true;
|
||||
} else if (shift < -1.0) {
|
||||
dsoSig->go_hDialPre(setted);
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QRectF DsoSignal::get_rect(DsoSetRegions type, int y, int right)
|
||||
{
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
|
||||
if (type == DSO_VDIAL)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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);
|
||||
else if (type == DSO_ACDC)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*2.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
else
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void DsoSignal::paint_measure(QPainter &p)
|
||||
{
|
||||
sr_status status;
|
||||
@@ -1020,58 +1263,125 @@ void DsoSignal::paint_measure(QPainter &p)
|
||||
const uint32_t count = (index == 0) ? status.ch0_pcnt : status.ch1_pcnt;
|
||||
double value_max = (_zero_off - _min) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_min = (_zero_off - _max) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
double value_p2p = value_max - value_min;
|
||||
_period = (count == 0) ? period * 10.0 : period * 10.0 / count;
|
||||
const int channel_count = _view->session().get_ch_num(SR_CHANNEL_DSO);
|
||||
uint64_t sample_rate = _dev_inst->get_sample_rate();
|
||||
_period = _period * 200.0 / (channel_count * sample_rate * 1.0 / SR_MHZ(1));
|
||||
QString max_string = abs(value_max) > 1000 ? QString::number(value_max/1000.0, 'f', 2) + "V" : QString::number(value_max, 'f', 2) + "mV";
|
||||
QString min_string = abs(value_min) > 1000 ? QString::number(value_min/1000.0, 'f', 2) + "V" : QString::number(value_min, 'f', 2) + "mV";
|
||||
QString period_string = abs(_period) > 1000000000 ? QString::number(_period/1000000000, 'f', 2) + "S" :
|
||||
_ms_string[DSO_MS_VMAX] = "Vmax: " + (abs(value_max) > 1000 ? QString::number(value_max/1000.0, 'f', 2) + "V" : QString::number(value_max, 'f', 2) + "mV");
|
||||
_ms_string[DSO_MS_VMIN] = "Vmin: " + (abs(value_min) > 1000 ? QString::number(value_min/1000.0, 'f', 2) + "V" : QString::number(value_min, 'f', 2) + "mV");
|
||||
_ms_string[DSO_MS_PERD] = "Perd: " + (abs(_period) > 1000000000 ? QString::number(_period/1000000000, 'f', 2) + "S" :
|
||||
abs(_period) > 1000000 ? QString::number(_period/1000000, 'f', 2) + "mS" :
|
||||
abs(_period) > 1000 ? QString::number(_period/1000, 'f', 2) + "uS" : QString::number(_period, 'f', 2) + "nS";
|
||||
QString freq_string = abs(_period) > 1000000 ? QString::number(1000000000/_period, 'f', 2) + "Hz" :
|
||||
abs(_period) > 1000 ? QString::number(1000000/_period, 'f', 2) + "kHz" : QString::number(1000/_period, 'f', 2) + "MHz";
|
||||
QColor measure_colour = _colour;
|
||||
measure_colour.setAlpha(180);
|
||||
p.setPen(measure_colour);
|
||||
p.drawText(QRectF(0, 100*index + UpMargin, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Max: ")+max_string+" ");
|
||||
p.drawText(QRectF(0, 100*index + UpMargin + 20, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Min: ")+min_string+" ");
|
||||
p.drawText(QRectF(0, 100*index + UpMargin + 40, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Period: ")+period_string+" ");
|
||||
p.drawText(QRectF(0, 100*index + UpMargin + 60, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Frequency: ")+freq_string+" ");
|
||||
abs(_period) > 1000 ? QString::number(_period/1000, 'f', 2) + "uS" : QString::number(_period, 'f', 2) + "nS");
|
||||
_ms_string[DSO_MS_FREQ] = "Freq: " + (abs(_period) > 1000000 ? QString::number(1000000000/_period, 'f', 2) + "Hz" :
|
||||
abs(_period) > 1000 ? QString::number(1000000/_period, 'f', 2) + "kHz" : QString::number(1000/_period, 'f', 2) + "MHz");
|
||||
_ms_string[DSO_MS_VP2P] = "Vp-p: " + (abs(value_p2p) > 1000 ? QString::number(value_p2p/1000.0, 'f', 2) + "V" : QString::number(value_p2p, 'f', 2) + "mV");
|
||||
|
||||
if (_autoV) {
|
||||
const uint8_t vscale = abs(_max - _min);
|
||||
if (_max == 0xff || _min == 0x00 || vscale > 0xCC) {
|
||||
go_vDialNext();
|
||||
} else if (vscale > 0x33) {
|
||||
_autoV = false;
|
||||
} else {
|
||||
go_vDialPre();
|
||||
if (_ms_show && _ms_en[DSO_MS_VRMS]) {
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (!snapshots.empty()) {
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
const double vrms = snapshot->cal_vrms(_zero_off, get_index());
|
||||
const double value_vrms = vrms * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
_ms_string[DSO_MS_VRMS] = "Vrms: " + (abs(value_vrms) > 1000 ? QString::number(value_vrms/1000.0, 'f', 2) + "V" : QString::number(value_vrms, 'f', 2) + "mV");
|
||||
}
|
||||
}
|
||||
|
||||
bool setted = false;
|
||||
if (_autoH) {
|
||||
const vector< boost::shared_ptr<Trace> > traces(_view->get_traces());
|
||||
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;
|
||||
}
|
||||
if (_ms_show && _ms_en[DSO_MS_VMEA]) {
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (!snapshots.empty()) {
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
const double vmean = snapshot->cal_vmean(get_index());
|
||||
const double value_vmean = (_zero_off - vmean) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
|
||||
_ms_string[DSO_MS_VMEA] = "Vmean: " + (abs(value_vmean) > 1000 ? QString::number(value_vmean/1000.0, 'f', 2) + "V" : QString::number(value_vmean, 'f', 2) + "mV");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_ms_string[DSO_MS_VMAX] = "Vmax: #####";
|
||||
_ms_string[DSO_MS_VMIN] = "Vmin: #####";
|
||||
_ms_string[DSO_MS_PERD] = "Perd: #####";
|
||||
_ms_string[DSO_MS_FREQ] = "Freq: #####";
|
||||
_ms_string[DSO_MS_VP2P] = "Vp-p: #####";
|
||||
_ms_string[DSO_MS_VRMS] = "Vrms: #####";
|
||||
_ms_string[DSO_MS_VMEA] = "Vmean: #####";
|
||||
}
|
||||
|
||||
QColor measure_colour = _colour;
|
||||
measure_colour.setAlpha(180);
|
||||
QColor back_colour = Qt::white;
|
||||
back_colour.setAlpha(100);
|
||||
|
||||
bool antialiasing = p.Antialiasing;
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(measure_colour);
|
||||
p.drawRoundedRect(_ms_rect[DSO_MS_BEGIN], MS_RectRad, MS_RectRad);
|
||||
const QPixmap gear_pix(":/icons/settings.png");
|
||||
const QPixmap show_pix(_ms_show ? ":/icons/shown.png" : ":/icons/hidden.png");
|
||||
if (_ms_gear_hover) {
|
||||
p.setBrush(back_colour);
|
||||
p.drawRoundedRect(_ms_gear_rect, MS_RectRad, MS_RectRad);
|
||||
} else if (_ms_show_hover) {
|
||||
p.setBrush(back_colour);
|
||||
p.drawRoundedRect(_ms_show_rect, MS_RectRad, MS_RectRad);
|
||||
}
|
||||
p.drawPixmap(_ms_gear_rect, gear_pix);
|
||||
p.drawPixmap(_ms_show_rect, show_pix);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(_ms_rect[DSO_MS_BEGIN], Qt::AlignCenter | Qt::AlignVCenter, "CH"+QString::number(index));
|
||||
|
||||
if (_ms_show) {
|
||||
p.setBrush(back_colour);
|
||||
int j = DSO_MS_BEGIN+1;
|
||||
for (int i=DSO_MS_BEGIN+1; i<DSO_MS_END; i++) {
|
||||
if (_ms_en[i]) {
|
||||
p.setPen(_colour);
|
||||
p.drawText(_ms_rect[j], Qt::AlignLeft | Qt::AlignVCenter, _ms_string[i]);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(_ms_rect[j], MS_RectRad, MS_RectRad);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
p.setRenderHint(QPainter::Antialiasing, antialiasing);
|
||||
|
||||
if (_autoV) {
|
||||
const uint8_t vscale = abs(_max - _min);
|
||||
if (_max == 0xff || _min == 0x00 || vscale > 0xCC) {
|
||||
go_vDialNext();
|
||||
} else if (vscale > 0x33) {
|
||||
_autoV = false;
|
||||
} else {
|
||||
go_vDialPre();
|
||||
}
|
||||
}
|
||||
|
||||
bool setted = false;
|
||||
if (_autoH) {
|
||||
const vector< boost::shared_ptr<Trace> > traces(_view->get_traces());
|
||||
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;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1092,10 +1402,31 @@ void DsoSignal::auto_set()
|
||||
|
||||
bool DsoSignal::measure(const QPointF &p)
|
||||
{
|
||||
if (_ms_gear_rect.contains(QPoint(p.x(), p.y()))) {
|
||||
_ms_gear_hover = true;
|
||||
_view->set_need_update(true);
|
||||
return false;
|
||||
} else if (_ms_gear_hover) {
|
||||
_view->set_need_update(true);
|
||||
_ms_gear_hover = false;
|
||||
}
|
||||
if (_ms_show_rect.contains(QPoint(p.x(), p.y()))) {
|
||||
_ms_show_hover = true;
|
||||
_view->set_need_update(true);
|
||||
return false;
|
||||
} else if (_ms_show_hover){
|
||||
_view->set_need_update(true);
|
||||
_ms_show_hover = false;
|
||||
}
|
||||
|
||||
_hover_en = false;
|
||||
if (!enabled())
|
||||
return false;
|
||||
|
||||
const QRectF window = get_view_rect();
|
||||
if (!window.contains(p))
|
||||
return false;
|
||||
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
|
||||
@@ -62,6 +62,41 @@ private:
|
||||
static const int DownMargin;
|
||||
static const int RightMargin;
|
||||
|
||||
public:
|
||||
enum DSO_MEASURE_TYPE {
|
||||
DSO_MS_BEGIN = 0,
|
||||
DSO_MS_FREQ,
|
||||
DSO_MS_PERD,
|
||||
DSO_MS_VMAX,
|
||||
DSO_MS_VMIN,
|
||||
DSO_MS_VRMS,
|
||||
DSO_MS_VMEA,
|
||||
DSO_MS_VP2P,
|
||||
DSO_MS_END,
|
||||
};
|
||||
|
||||
enum DsoSetRegions {
|
||||
DSO_NONE = -1,
|
||||
DSO_VDIAL,
|
||||
DSO_HDIAL,
|
||||
DSO_VDEC,
|
||||
DSO_VINC,
|
||||
DSO_HDEC,
|
||||
DSO_HINC,
|
||||
DSO_CHEN,
|
||||
DSO_ACDC,
|
||||
DSO_X1,
|
||||
DSO_X10,
|
||||
DSO_X100,
|
||||
};
|
||||
|
||||
private:
|
||||
static const uint16_t MS_RectRad = 5;
|
||||
static const uint16_t MS_IconSize = 16;
|
||||
static const uint16_t MS_RectWidth = 120;
|
||||
static const uint16_t MS_RectMargin = 10;
|
||||
static const uint16_t MS_RectHeight = 25;
|
||||
|
||||
public:
|
||||
DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
boost::shared_ptr<pv::data::Dso> data,
|
||||
@@ -101,9 +136,7 @@ public:
|
||||
void set_factor(uint64_t factor);
|
||||
uint64_t get_factor();
|
||||
|
||||
bool update_vDial();
|
||||
bool update_hDial();
|
||||
bool update_acCoupling();
|
||||
bool load_settings();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -158,8 +191,24 @@ public:
|
||||
|
||||
QRectF get_trig_rect(int left, int right) const;
|
||||
|
||||
void set_ms_show(bool show);
|
||||
bool get_ms_show() const;
|
||||
bool get_ms_show_hover() const;
|
||||
bool get_ms_gear_hover() const;
|
||||
void set_ms_en(int index, bool en);
|
||||
bool get_ms_en(int index) const;
|
||||
QString get_ms_string(int index) const;
|
||||
|
||||
QRectF get_rect(DsoSetRegions type, int y, int right);
|
||||
|
||||
bool mouse_double_click(int right, const QPoint pt);
|
||||
|
||||
bool mouse_press(int right, const QPoint pt);
|
||||
|
||||
bool mouse_wheel(int right, const QPoint pt, const int shift);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, bool hover, int action);
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
private:
|
||||
void paint_trace(QPainter &p,
|
||||
@@ -200,6 +249,15 @@ private:
|
||||
uint64_t _hover_index;
|
||||
QPointF _hover_point;
|
||||
double _hover_value;
|
||||
|
||||
QRect _ms_gear_rect;
|
||||
QRect _ms_show_rect;
|
||||
QRect _ms_rect[DSO_MS_END-DSO_MS_BEGIN];
|
||||
bool _ms_gear_hover;
|
||||
bool _ms_show_hover;
|
||||
bool _ms_show;
|
||||
bool _ms_en[DSO_MS_END-DSO_MS_BEGIN];
|
||||
QString _ms_string[DSO_MS_END-DSO_MS_BEGIN];
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -196,13 +196,12 @@ const std::vector< std::pair<uint64_t, bool> > GroupSignal::cur_edges() const
|
||||
|
||||
}
|
||||
|
||||
void GroupSignal::paint_type_options(QPainter &p, int right, bool hover, int action)
|
||||
void GroupSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
(void)hover;
|
||||
(void)action;
|
||||
(void)pt;
|
||||
|
||||
int y = get_y();
|
||||
const QRectF group_index_rect = get_rect("groupIndex", y, right);
|
||||
const QRectF group_index_rect = get_rect(CHNLREG, y, right);
|
||||
QString index_string;
|
||||
int last_index;
|
||||
p.setPen(Qt::transparent);
|
||||
@@ -224,5 +223,18 @@ void GroupSignal::paint_type_options(QPainter &p, int right, bool hover, int act
|
||||
p.drawText(group_index_rect, Qt::AlignRight | Qt::AlignVCenter, index_string);
|
||||
}
|
||||
|
||||
QRectF GroupSignal::get_rect(GroupSetRegions type, int y, int right)
|
||||
{
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
|
||||
if (type == CHNLREG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * SquareNum, SquareWidth);
|
||||
else
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -48,6 +48,11 @@ private:
|
||||
|
||||
static const float EnvelopeThreshold;
|
||||
|
||||
enum GroupSetRegions{
|
||||
NONEREG = -1,
|
||||
CHNLREG,
|
||||
};
|
||||
|
||||
public:
|
||||
GroupSignal(QString name,
|
||||
boost::shared_ptr<pv::data::Group> data,
|
||||
@@ -74,8 +79,10 @@ public:
|
||||
|
||||
const std::vector< std::pair<uint64_t, bool> > cur_edges() const;
|
||||
|
||||
QRectF get_rect(GroupSetRegions type, int y, int right);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, bool hover, int action);
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
private:
|
||||
void paint_trace(QPainter &p,
|
||||
|
||||
@@ -118,7 +118,6 @@ void Header::paintEvent(QPaintEvent*)
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
|
||||
|
||||
const int w = width();
|
||||
int action = 0;
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
|
||||
@@ -129,11 +128,7 @@ void Header::paintEvent(QPaintEvent*)
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
{
|
||||
assert(t);
|
||||
|
||||
const int y = t->get_y();
|
||||
const bool highlight = !dragging &&
|
||||
(action = t->pt_in_rect(y, w, _mouse_point));
|
||||
t->paint_label(painter, w, highlight, action);
|
||||
t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point);
|
||||
}
|
||||
|
||||
painter.end();
|
||||
@@ -145,7 +140,6 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
int action;
|
||||
|
||||
if (event->button() & Qt::LeftButton) {
|
||||
_mouse_down_point = event->pos();
|
||||
@@ -157,14 +151,9 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
make_pair(t, t->get_v_offset()));
|
||||
|
||||
// Select the Trace if it has been clicked
|
||||
const boost::shared_ptr<Trace> mTrace =
|
||||
get_mTrace(action, event->pos());
|
||||
if (action == Trace::LABEL && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
dsoSig->auto_set();
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
if (t->mouse_double_click(width(), event->pos()))
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -213,93 +202,12 @@ void Header::mousePressEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
mTrace->set_old_v_offset(mTrace->get_v_offset());
|
||||
} else if (action == Trace::POSTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::POSTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::POSTRIG);
|
||||
} else if (action == Trace::HIGTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::HIGTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::HIGTRIG);
|
||||
} else if (action == Trace::NEGTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::NEGTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::NEGTRIG);
|
||||
} else if (action == Trace::LOWTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::LOWTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::LOWTRIG);
|
||||
} else if (action == Trace::EDGETRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::EDGETRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::EDGETRIG);
|
||||
} else if (action == Trace::VDIAL && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_hDialActive(false);
|
||||
if (t != mTrace) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace))
|
||||
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
|
||||
} else if (action == Trace::HDIAL && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
if (dsoSig->get_hDialActive()) {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if(dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
dsoSig->set_hDialActive(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
if(dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
dsoSig->set_hDialActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (action == Trace::CHEN && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
if (!_view.session().get_data_lock())
|
||||
dsoSig->set_enable(!dsoSig->enabled());
|
||||
}
|
||||
} else if (action == Trace::ACDC && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
if (strcmp(_view.session().get_device()->dev_inst()->driver->name, "DSLogic") == 0)
|
||||
dsoSig->set_acCoupling((dsoSig->get_acCoupling()+1)%2);
|
||||
else
|
||||
dsoSig->set_acCoupling((dsoSig->get_acCoupling()+1)%3);
|
||||
}
|
||||
} else if (action == Trace::X1 && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
dsoSig->set_factor(1);
|
||||
}
|
||||
} else if (action == Trace::X10 && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
dsoSig->set_factor(10);
|
||||
}
|
||||
} else if (action == Trace::X100 && mTrace) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
dsoSig->set_factor(100);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
if (t->mouse_press(width(), event->pos()))
|
||||
break;
|
||||
|
||||
if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
// Unselect all other Traces because the Ctrl is not
|
||||
// pressed
|
||||
@@ -350,27 +258,9 @@ void Header::wheelEvent(QWheelEvent *event)
|
||||
_view.get_traces());
|
||||
// Vertical scrolling
|
||||
double shift = event->delta() / 20.0;
|
||||
bool setted = false;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
if (dsoSig->get_vDialActive()) {
|
||||
if (shift > 1.0)
|
||||
dsoSig->go_vDialNext();
|
||||
else if (shift < -1.0)
|
||||
dsoSig->go_vDialPre();
|
||||
break;
|
||||
} else if (dsoSig->get_hDialActive()){
|
||||
if (shift > 1.0)
|
||||
dsoSig->go_hDialNext(setted);
|
||||
else if (shift < -1.0)
|
||||
dsoSig->go_hDialPre(setted);
|
||||
else
|
||||
break;
|
||||
setted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
if (t->mouse_wheel(width(), event->pos(), shift))
|
||||
break;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,23 +70,24 @@ LogicSignal::LogicSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
boost::shared_ptr<data::Logic> data,
|
||||
const sr_channel * const probe) :
|
||||
Signal(dev_inst, probe, SR_CHANNEL_LOGIC),
|
||||
_data(data)
|
||||
_data(data),
|
||||
_trig(NONTRIG)
|
||||
{
|
||||
assert(probe->index >= 0);
|
||||
_colour = SignalColours[probe->index % countof(SignalColours)];
|
||||
}
|
||||
|
||||
LogicSignal::LogicSignal(const Signal &s,
|
||||
LogicSignal::LogicSignal(boost::shared_ptr<view::LogicSignal> s,
|
||||
boost::shared_ptr<pv::data::Logic> data,
|
||||
const sr_channel * const probe) :
|
||||
Signal(s, probe),
|
||||
_data(data)
|
||||
Signal(*s.get(), probe),
|
||||
_data(data),
|
||||
_trig(s->get_trig())
|
||||
{
|
||||
assert(probe->index >= 0);
|
||||
}
|
||||
|
||||
LogicSignal::~LogicSignal()
|
||||
{
|
||||
_cur_edges.clear();
|
||||
}
|
||||
|
||||
const sr_channel* LogicSignal::probe() const
|
||||
@@ -104,6 +105,39 @@ boost::shared_ptr<pv::data::Logic> LogicSignal::logic_data() const
|
||||
return _data;
|
||||
}
|
||||
|
||||
LogicSignal::LogicSetRegions LogicSignal::get_trig() const
|
||||
{
|
||||
return _trig;
|
||||
}
|
||||
|
||||
void LogicSignal::set_trig(int trig)
|
||||
{
|
||||
if (trig > NONTRIG && trig <= EDGTRIG)
|
||||
_trig = (LogicSetRegions)trig;
|
||||
else
|
||||
_trig = NONTRIG;
|
||||
}
|
||||
|
||||
void LogicSignal::commit_trig()
|
||||
{
|
||||
|
||||
if (_trig == NONTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'X', 'X');
|
||||
else {
|
||||
ds_trigger_set_en(true);
|
||||
if (_trig == POSTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
|
||||
else if (_trig == HIGTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), '1', 'X');
|
||||
else if (_trig == NEGTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
|
||||
else if (_trig == LOWTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), '0', 'X');
|
||||
else if (_trig == EDGTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
|
||||
}
|
||||
}
|
||||
|
||||
void LogicSignal::paint_mid(QPainter &p, int left, int right)
|
||||
{
|
||||
using pv::view::View;
|
||||
@@ -206,35 +240,30 @@ const std::vector< std::pair<uint64_t, bool> > LogicSignal::cur_edges() const
|
||||
return _cur_edges;
|
||||
}
|
||||
|
||||
void LogicSignal::paint_type_options(QPainter &p, int right, bool hover, int action)
|
||||
void LogicSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
int y = get_y();
|
||||
const QRectF posTrig_rect = get_rect("posTrig", y, right);
|
||||
const QRectF higTrig_rect = get_rect("higTrig", y, right);
|
||||
const QRectF negTrig_rect = get_rect("negTrig", y, right);
|
||||
const QRectF lowTrig_rect = get_rect("lowTrig", y, right);
|
||||
const QRectF edgeTrig_rect = get_rect("edgeTrig", y, right);
|
||||
const QRectF posTrig_rect = get_rect(POSTRIG, y, right);
|
||||
const QRectF higTrig_rect = get_rect(HIGTRIG, y, right);
|
||||
const QRectF negTrig_rect = get_rect(NEGTRIG, y, right);
|
||||
const QRectF lowTrig_rect = get_rect(LOWTRIG, y, right);
|
||||
const QRectF edgeTrig_rect = get_rect(EDGTRIG, y, right);
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(((hover && action == POSTRIG) || (_trig == POSTRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.setBrush(posTrig_rect.contains(pt) ? dsYellow.darker() :
|
||||
(_trig == POSTRIG) ? dsYellow : dsBlue);
|
||||
p.drawRect(posTrig_rect);
|
||||
p.setBrush(((hover && action == HIGTRIG) || (_trig == HIGTRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.setBrush(higTrig_rect.contains(pt) ? dsYellow.darker() :
|
||||
(_trig == HIGTRIG) ? dsYellow : dsBlue);
|
||||
p.drawRect(higTrig_rect);
|
||||
p.setBrush(((hover && action == NEGTRIG) || (_trig == NEGTRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.setBrush(negTrig_rect.contains(pt) ? dsYellow.darker() :
|
||||
(_trig == NEGTRIG) ? dsYellow : dsBlue);
|
||||
p.drawRect(negTrig_rect);
|
||||
p.setBrush(((hover && action == LOWTRIG) || (_trig == LOWTRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.setBrush(lowTrig_rect.contains(pt) ? dsYellow.darker() :
|
||||
(_trig == LOWTRIG) ? dsYellow : dsBlue);
|
||||
p.drawRect(lowTrig_rect);
|
||||
p.setBrush(((hover && action == EDGETRIG) || (_trig == EDGETRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.setBrush(edgeTrig_rect.contains(pt) ? dsYellow.darker() :
|
||||
(_trig == EDGTRIG) ? dsYellow : dsBlue);
|
||||
p.drawRect(edgeTrig_rect);
|
||||
|
||||
p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
|
||||
@@ -325,5 +354,107 @@ bool LogicSignal::measure(const QPointF &p, uint64_t &index0, uint64_t &index1,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LogicSignal::edges(const QPointF &p, uint64_t start, uint64_t &rising, uint64_t &falling) const
|
||||
{
|
||||
uint64_t index, end;
|
||||
const float gap = abs(p.y() - get_y());
|
||||
if (gap < get_signalHeight() * 0.5) {
|
||||
const deque< boost::shared_ptr<pv::data::LogicSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return false;
|
||||
|
||||
const boost::shared_ptr<pv::data::LogicSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
if (snapshot->buf_null())
|
||||
return false;
|
||||
|
||||
end = _data->samplerate() * (_view->offset() - _data->get_start_time() + p.x() * _view->scale());
|
||||
index = min(start, end);
|
||||
end = max(start, end);
|
||||
start = index;
|
||||
if (end > (snapshot->get_sample_count() - 1))
|
||||
return false;
|
||||
|
||||
const uint64_t sig_mask = 1ULL << get_index();
|
||||
bool sample = snapshot->get_sample(start) & sig_mask;
|
||||
|
||||
rising = 0;
|
||||
falling = 0;
|
||||
do {
|
||||
if (snapshot->get_nxt_edge(index, sample, snapshot->get_sample_count(), 1, get_index())) {
|
||||
if (index > end)
|
||||
break;
|
||||
rising += !sample;
|
||||
falling += sample;
|
||||
sample = !sample;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while(index <= end);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LogicSignal::mouse_press(int right, const QPoint pt)
|
||||
{
|
||||
int y = get_y();
|
||||
const QRectF posTrig = get_rect(POSTRIG, y, right);
|
||||
const QRectF higTrig = get_rect(HIGTRIG, y, right);
|
||||
const QRectF negTrig = get_rect(NEGTRIG, y, right);
|
||||
const QRectF lowTrig = get_rect(LOWTRIG, y, right);
|
||||
const QRectF edgeTrig = get_rect(EDGTRIG, y, right);
|
||||
|
||||
if (posTrig.contains(pt))
|
||||
set_trig((_trig == POSTRIG) ? NONTRIG : POSTRIG);
|
||||
else if (higTrig.contains(pt))
|
||||
set_trig((_trig == HIGTRIG) ? NONTRIG : HIGTRIG);
|
||||
else if (negTrig.contains(pt))
|
||||
set_trig((_trig == NEGTRIG) ? NONTRIG : NEGTRIG);
|
||||
else if (lowTrig.contains(pt))
|
||||
set_trig((_trig == LOWTRIG) ? NONTRIG : LOWTRIG);
|
||||
else if (edgeTrig.contains(pt))
|
||||
set_trig((_trig == EDGTRIG) ? NONTRIG : EDGTRIG);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QRectF LogicSignal::get_rect(LogicSetRegions type, int y, int right)
|
||||
{
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
|
||||
if (type == POSTRIG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (type == HIGTRIG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (type == NEGTRIG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 2 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (type == LOWTRIG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 3 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (type == EDGTRIG)
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 4 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -53,12 +53,21 @@ private:
|
||||
static const int StateHeight;
|
||||
static const int StateRound;
|
||||
|
||||
enum LogicSetRegions{
|
||||
NONTRIG = 0,
|
||||
POSTRIG,
|
||||
HIGTRIG,
|
||||
NEGTRIG,
|
||||
LOWTRIG,
|
||||
EDGTRIG,
|
||||
};
|
||||
|
||||
public:
|
||||
LogicSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
|
||||
boost::shared_ptr<pv::data::Logic> data,
|
||||
const sr_channel * const probe);
|
||||
|
||||
LogicSignal(const Signal &s,
|
||||
LogicSignal(boost::shared_ptr<view::LogicSignal> s,
|
||||
boost::shared_ptr<pv::data::Logic> data,
|
||||
const sr_channel * const probe);
|
||||
|
||||
@@ -70,6 +79,13 @@ public:
|
||||
|
||||
boost::shared_ptr<pv::data::Logic> logic_data() const;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
LogicSetRegions get_trig() const;
|
||||
void set_trig(int trig);
|
||||
void commit_trig();
|
||||
|
||||
/**
|
||||
* Paints the signal with a QPainter
|
||||
* @param p the QPainter to paint into.
|
||||
@@ -82,8 +98,14 @@ public:
|
||||
|
||||
bool measure(const QPointF &p, uint64_t &index0, uint64_t &index1, uint64_t &index2) const;
|
||||
|
||||
bool edges(const QPointF &p, uint64_t start, uint64_t &rising, uint64_t &falling) const;
|
||||
|
||||
bool mouse_press(int right, const QPoint pt);
|
||||
|
||||
QRectF get_rect(LogicSetRegions type, int y, int right);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, bool hover, int action);
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
private:
|
||||
|
||||
@@ -95,6 +117,7 @@ private:
|
||||
private:
|
||||
boost::shared_ptr<pv::data::Logic> _data;
|
||||
std::vector< std::pair<uint64_t, bool> > _cur_edges;
|
||||
LogicSetRegions _trig;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -42,7 +42,7 @@ const QColor Trace::dsYellow = QColor(238, 178, 17, 255);
|
||||
const QColor Trace::dsRed = QColor(213, 15, 37, 255);
|
||||
const QColor Trace::dsGreen = QColor(0, 153, 37, 200);
|
||||
const QColor Trace::dsGray = QColor(0x88, 0x8A, 0x85, 60);
|
||||
const QColor Trace::dsFore = QColor(0xff, 0xff, 0xff, 100);
|
||||
const QColor Trace::dsFore = QColor(0xff, 0xff, 0xff, 60);
|
||||
const QColor Trace::dsBack = QColor(0x16, 0x18, 0x23, 180);
|
||||
const QColor Trace::dsDisable = QColor(0x88, 0x8A, 0x85, 200);
|
||||
const QColor Trace::dsActive = QColor(17, 133, 209, 255);
|
||||
@@ -53,14 +53,13 @@ const QPen Trace::SignalAxisPen = QColor(128, 128, 128, 64);
|
||||
const QPen Trace::AxisPen(QColor(128, 128, 128, 64));
|
||||
const int Trace::LabelHitPadding = 2;
|
||||
|
||||
Trace::Trace(QString name, int index, int type) :
|
||||
Trace::Trace(QString name, uint16_t index, int type) :
|
||||
_view(NULL),
|
||||
_name(name),
|
||||
_v_offset(INT_MAX),
|
||||
_type(type),
|
||||
_sec_index(0),
|
||||
_signalHeight(30),
|
||||
_trig(0)
|
||||
_signalHeight(30)
|
||||
{
|
||||
_index_list.push_back(index);
|
||||
}
|
||||
@@ -72,8 +71,7 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
|
||||
_type(type),
|
||||
_index_list(index_list),
|
||||
_sec_index(sec_index),
|
||||
_signalHeight(30),
|
||||
_trig(0)
|
||||
_signalHeight(30)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,7 +85,6 @@ Trace::Trace(const Trace &t) :
|
||||
_sec_index(t._sec_index),
|
||||
_old_v_offset(t._old_v_offset),
|
||||
_signalHeight(t._signalHeight),
|
||||
_trig(t._trig),
|
||||
_text_size(t._text_size)
|
||||
{
|
||||
}
|
||||
@@ -180,28 +177,6 @@ void Trace::set_signalHeight(int height)
|
||||
_signalHeight = height;
|
||||
}
|
||||
|
||||
int Trace::get_trig() const
|
||||
{
|
||||
return _trig;
|
||||
}
|
||||
|
||||
void Trace::set_trig(int trig)
|
||||
{
|
||||
_trig = trig;
|
||||
if (trig == 0)
|
||||
ds_trigger_probe_set(_index_list.front(), 'X', 'X');
|
||||
else if (trig == POSTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
|
||||
else if (trig == HIGTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), '1', 'X');
|
||||
else if (trig == NEGTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
|
||||
else if (trig == LOWTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), '0', 'X');
|
||||
else if (trig == EDGETRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
|
||||
}
|
||||
|
||||
void Trace::set_view(pv::view::View *view)
|
||||
{
|
||||
assert(view);
|
||||
@@ -231,7 +206,7 @@ void Trace::paint_fore(QPainter &p, int left, int right)
|
||||
(void)right;
|
||||
}
|
||||
|
||||
void Trace::paint_label(QPainter &p, int right, bool hover, int action)
|
||||
void Trace::paint_label(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
compute_text_size(p);
|
||||
const int y = get_y();
|
||||
@@ -251,7 +226,7 @@ void Trace::paint_label(QPainter &p, int right, bool hover, int action)
|
||||
p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
|
||||
|
||||
// Paint the trigButton
|
||||
paint_type_options(p, right, hover, action);
|
||||
paint_type_options(p, right, pt);
|
||||
|
||||
// Paint the label
|
||||
if (enabled()) {
|
||||
@@ -265,9 +240,9 @@ void Trace::paint_label(QPainter &p, int right, bool hover, int action)
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
if (_type == SR_CHANNEL_DSO)
|
||||
p.setBrush(((hover && action == LABEL) || selected()) ? _colour.darker() : _colour);
|
||||
p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour);
|
||||
else
|
||||
p.setBrush(((hover && action == LABEL) || selected()) ? dsYellow : dsBlue);
|
||||
p.setBrush((label_rect.contains(pt) || selected()) ? dsYellow : dsBlue);
|
||||
p.drawPolygon(points, countof(points));
|
||||
|
||||
p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
|
||||
@@ -288,65 +263,47 @@ void Trace::paint_label(QPainter &p, int right, bool hover, int action)
|
||||
}
|
||||
}
|
||||
|
||||
void Trace::paint_type_options(QPainter &p, int right, bool hover, int action)
|
||||
void Trace::paint_type_options(QPainter &p, int right, const QPoint pt)
|
||||
{
|
||||
(void)p;
|
||||
(void)right;
|
||||
(void)hover;
|
||||
(void)action;
|
||||
(void)pt;
|
||||
}
|
||||
|
||||
bool Trace::mouse_double_click(int right, const QPoint pt)
|
||||
{
|
||||
(void)right;
|
||||
(void)pt;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Trace::mouse_press(int right, const QPoint pt)
|
||||
{
|
||||
(void)right;
|
||||
(void)pt;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Trace::mouse_wheel(int right, const QPoint pt, const int shift)
|
||||
{
|
||||
(void)right;
|
||||
(void)pt;
|
||||
(void)shift;
|
||||
return false;
|
||||
}
|
||||
|
||||
int Trace::pt_in_rect(int y, int right, const QPoint &point)
|
||||
{
|
||||
const QRectF color = get_rect("color", y, right);
|
||||
const QRectF name = get_rect("name", y, right);
|
||||
const QRectF posTrig = get_rect("posTrig", y, right);
|
||||
const QRectF higTrig = get_rect("higTrig", y, right);
|
||||
const QRectF negTrig = get_rect("negTrig", y, right);
|
||||
const QRectF lowTrig = get_rect("lowTrig", y, right);
|
||||
const QRectF edgeTrig = get_rect("edgeTrig", y, right);
|
||||
const QRectF label = get_rect("label", get_zeroPos(), right);
|
||||
const QRectF vDial = get_rect("vDial", y, right);
|
||||
const QRectF x1 = get_rect("x1", y, right);
|
||||
const QRectF x10 = get_rect("x10", y, right);
|
||||
const QRectF x100 = get_rect("x100", y, right);
|
||||
const QRectF hDial = get_rect("hDial", y, right);
|
||||
const QRectF chEn = get_rect("chEn", y, right);
|
||||
const QRectF acdc = get_rect("acdc", y, right);
|
||||
const QRectF dsoTrig = get_rect("dsoTrig", 0, right);
|
||||
|
||||
if (color.contains(point) && enabled())
|
||||
return COLOR;
|
||||
else if (name.contains(point) && enabled())
|
||||
return NAME;
|
||||
else if (posTrig.contains(point) && _type == SR_CHANNEL_LOGIC)
|
||||
return POSTRIG;
|
||||
else if (higTrig.contains(point) && _type == SR_CHANNEL_LOGIC)
|
||||
return HIGTRIG;
|
||||
else if (negTrig.contains(point) && _type == SR_CHANNEL_LOGIC)
|
||||
return NEGTRIG;
|
||||
else if (lowTrig.contains(point) && _type == SR_CHANNEL_LOGIC)
|
||||
return LOWTRIG;
|
||||
else if (edgeTrig.contains(point) && _type == SR_CHANNEL_LOGIC)
|
||||
return EDGETRIG;
|
||||
else if (label.contains(point) && enabled())
|
||||
return LABEL;
|
||||
else if (vDial.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return VDIAL;
|
||||
else if (x1.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return X1;
|
||||
else if (x10.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return X10;
|
||||
else if (x100.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return X100;
|
||||
else if (hDial.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return HDIAL;
|
||||
else if (chEn.contains(point) && _type == SR_CHANNEL_DSO)
|
||||
return CHEN;
|
||||
else if (acdc.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return ACDC;
|
||||
else if (dsoTrig.contains(point) && _type == SR_CHANNEL_DSO && enabled())
|
||||
return DSOTRIG;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -381,71 +338,6 @@ QRectF Trace::get_rect(const char *s, int y, int right)
|
||||
right - 1.5f * label_size.width(),
|
||||
y - SquareWidth / 2,
|
||||
label_size.width(), label_size.height());
|
||||
else if (!strcmp(s, "posTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "higTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "negTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 2 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "lowTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 3 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "edgeTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 4 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "groupIndex"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * SquareNum, SquareWidth);
|
||||
else if (!strcmp(s, "vDial"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (!strcmp(s, "x1"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.85,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (!strcmp(s, "x10"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.55,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (!strcmp(s, "x100"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin - 45,
|
||||
y - SquareWidth - SquareWidth * (SquareNum-1) * 0.25,
|
||||
SquareWidth * 1.75, SquareWidth);
|
||||
else if (!strcmp(s, "hDial"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y + SquareWidth * 1.5,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (!strcmp(s, "chEn"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
else if (!strcmp(s, "acdc"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*2.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
else
|
||||
return QRectF(
|
||||
2,
|
||||
|
||||
@@ -45,7 +45,7 @@ class Trace : public SelectableItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
protected:
|
||||
static const int Margin = 3;
|
||||
static const int SquareNum = 5;
|
||||
static const QPen AxisPen;
|
||||
@@ -55,20 +55,7 @@ public:
|
||||
static const int SquareWidth = 20;
|
||||
static const int COLOR = 1;
|
||||
static const int NAME = 2;
|
||||
static const int POSTRIG = 3;
|
||||
static const int HIGTRIG = 4;
|
||||
static const int NEGTRIG = 5;
|
||||
static const int LOWTRIG = 6;
|
||||
static const int EDGETRIG = 7;
|
||||
static const int LABEL = 8;
|
||||
static const int VDIAL = 9;
|
||||
static const int HDIAL = 10;
|
||||
static const int CHEN = 11;
|
||||
static const int ACDC = 12;
|
||||
static const int DSOTRIG = 13;
|
||||
static const int X1 = 14;
|
||||
static const int X10 = 15;
|
||||
static const int X100 = 16;
|
||||
|
||||
static const QColor dsBlue;
|
||||
static const QColor dsYellow;
|
||||
@@ -84,7 +71,7 @@ public:
|
||||
static const QPen SignalAxisPen;
|
||||
|
||||
protected:
|
||||
Trace(QString name, int index, int type);
|
||||
Trace(QString name, uint16_t index, int type);
|
||||
Trace(QString name, std::list<int> index_list, int type, int sec_index);
|
||||
|
||||
/**
|
||||
@@ -166,12 +153,6 @@ public:
|
||||
|
||||
virtual int get_zeroPos();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int get_trig() const;
|
||||
void set_trig(int trig);
|
||||
|
||||
/**
|
||||
* Returns true if the trace is visible and enabled.
|
||||
*/
|
||||
@@ -208,10 +189,9 @@ public:
|
||||
* @param p the QPainter to paint into.
|
||||
* @param right the x-coordinate of the right edge of the header
|
||||
* area.
|
||||
* @param hover true if the label is being hovered over by the mouse.
|
||||
* @param action mouse position for hover
|
||||
* @param point the mouse point.
|
||||
*/
|
||||
virtual void paint_label(QPainter &p, int right, bool hover, int action);
|
||||
virtual void paint_label(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
/**
|
||||
* Gets the y-offset of the axis.
|
||||
@@ -250,6 +230,12 @@ public:
|
||||
|
||||
virtual QRectF get_view_rect() const;
|
||||
|
||||
virtual bool mouse_double_click(int right, const QPoint pt);
|
||||
|
||||
virtual bool mouse_press(int right, const QPoint pt);
|
||||
|
||||
virtual bool mouse_wheel(int right, const QPoint pt, const int shift);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@@ -274,10 +260,9 @@ protected:
|
||||
* @param p the QPainter to paint into.
|
||||
* @param right the x-coordinate of the right edge of the header
|
||||
* area.
|
||||
* @param hover true if the label is being hovered over by the mouse.
|
||||
* @param action mouse position for hover
|
||||
* @param point the mouse point.
|
||||
*/
|
||||
virtual void paint_type_options(QPainter &p, int right, bool hover, int action);
|
||||
virtual void paint_type_options(QPainter &p, int right, const QPoint pt);
|
||||
|
||||
private:
|
||||
|
||||
@@ -307,7 +292,6 @@ protected:
|
||||
int _sec_index;
|
||||
int _old_v_offset;
|
||||
int _signalHeight;
|
||||
int _trig;
|
||||
|
||||
QSizeF _text_size;
|
||||
};
|
||||
|
||||
@@ -57,6 +57,7 @@ const int View::LabelMarginWidth = 70;
|
||||
const int View::RulerHeight = 50;
|
||||
|
||||
const int View::MaxScrollValue = INT_MAX / 2;
|
||||
const int View::MaxHeightUnit = 20;
|
||||
|
||||
//const int View::SignalHeight = 30;s
|
||||
const int View::SignalMargin = 10;
|
||||
@@ -225,6 +226,7 @@ void View::zoom(double steps, int offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_offset = cursor_offset - _scale * offset;
|
||||
_offset = max(min(_offset, get_max_offset()), get_min_offset());
|
||||
|
||||
@@ -470,6 +472,7 @@ void View::update_scale()
|
||||
void View::signals_changed()
|
||||
{
|
||||
int total_rows = 0;
|
||||
uint8_t max_height = MaxHeightUnit;
|
||||
const vector< boost::shared_ptr<Trace> > traces(get_traces());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
{
|
||||
@@ -483,7 +486,16 @@ void View::signals_changed()
|
||||
- horizontalScrollBar()->height()
|
||||
- 2 * SignalMargin * traces.size()) * 1.0 / total_rows;
|
||||
|
||||
_signalHeight = (int)((height <= 0) ? 1 : height);
|
||||
if (_session.get_device()->dev_inst()->mode == LOGIC) {
|
||||
GVariant* gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_HEIGHT_VALUE);
|
||||
if (gvar != NULL) {
|
||||
max_height = (g_variant_get_byte(gvar) + 1) * MaxHeightUnit;
|
||||
g_variant_unref(gvar);
|
||||
}
|
||||
_signalHeight = (int)((height <= 0) ? 1 : (height >= max_height) ? max_height : height);
|
||||
} else {
|
||||
_signalHeight = (int)((height <= 0) ? 1 : height);
|
||||
}
|
||||
_spanY = _signalHeight + 2 * SignalMargin;
|
||||
int next_v_offset = SignalMargin;
|
||||
BOOST_FOREACH(boost::shared_ptr<Trace> t, traces) {
|
||||
@@ -494,6 +506,7 @@ void View::signals_changed()
|
||||
next_v_offset += traceHeight + 2 * SignalMargin;
|
||||
}
|
||||
|
||||
_viewport->clear_measure();
|
||||
header_updated();
|
||||
normalize_layout();
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
static const int RulerHeight;
|
||||
|
||||
static const int MaxScrollValue;
|
||||
static const int MaxHeightUnit;
|
||||
|
||||
public:
|
||||
//static const int SignalHeight;
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
#include "../data/logic.h"
|
||||
#include "../data/logicsnapshot.h"
|
||||
#include "../sigsession.h"
|
||||
#include "../dialogs/dsomeasure.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QStyleOption>
|
||||
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
@@ -70,7 +72,7 @@ Viewport::Viewport(View &parent) :
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setAutoFillBackground(true);
|
||||
setBackgroundRole(QPalette::Base);
|
||||
setBackgroundRole(QPalette::Base);
|
||||
|
||||
//setFixedSize(QSize(600, 400));
|
||||
_mm_width = "#####";
|
||||
@@ -379,10 +381,11 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
const double samples_per_pixel = _view.session().get_device()->get_sample_rate() * _view.scale();
|
||||
while (i != _view.get_cursorList().end()) {
|
||||
cursorX = (*i)->index()/samples_per_pixel - (_view.offset() / _view.scale());
|
||||
if ((*i)->grabbed())
|
||||
if ((*i)->grabbed()) {
|
||||
_view.get_ruler()->rel_grabbed_cursor();
|
||||
else if (qAbs(cursorX - event->pos().x()) <= HitCursorMargin) {
|
||||
} else if (qAbs(cursorX - event->pos().x()) <= HitCursorMargin) {
|
||||
_view.get_ruler()->set_grabbed_cursor(*i);
|
||||
_measure_type = LOGIC_CURS;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
@@ -396,13 +399,24 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
if (!s->enabled())
|
||||
continue;
|
||||
boost::shared_ptr<DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<DsoSignal>(s)) &&
|
||||
dsoSig->get_trig_rect(0, _view.get_view_width()).contains(_mouse_point)) {
|
||||
_drag_sig = s;
|
||||
break;
|
||||
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
|
||||
if (dsoSig->get_trig_rect(0, _view.get_view_width()).contains(_mouse_point)) {
|
||||
_drag_sig = s;
|
||||
break;
|
||||
} else if (dsoSig->get_ms_show_hover()) {
|
||||
dsoSig->set_ms_show(!dsoSig->get_ms_show());
|
||||
break;
|
||||
} else if (dsoSig->get_ms_gear_hover()) {
|
||||
pv::dialogs::DsoMeasure dsoMeasureDialog(this, dsoSig);
|
||||
dsoMeasureDialog.exec();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_measure_type == LOGIC_FREQ)
|
||||
_measure_type = NO_MEASURE;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -444,7 +458,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
_dso_xm_index[i-1] = min(_dso_xm_index[i-1], _dso_xm_index[i]);
|
||||
_dso_xm_index[i] = max_index;
|
||||
}
|
||||
_dso_xm_stage = (++_dso_xm_stage) % (DsoMeasureStages + 1);
|
||||
_dso_xm_stage = (_dso_xm_stage + 1) % (DsoMeasureStages + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,7 +484,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
(_mouse_down_point - event->pos()).x() *
|
||||
_view.scale());
|
||||
_drag_strength = (_mouse_down_point - event->pos()).x();
|
||||
measure();
|
||||
//measure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,18 +525,45 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
if(_drag_sig)
|
||||
_drag_sig.reset();
|
||||
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_time.elapsed();
|
||||
if (abs(_drag_strength) < MinorDragOffsetUp && abs(strength) > MinorDragRateUp) {
|
||||
_drag_strength = _drag_strength;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
} else if (abs(strength) > DragTimerInterval) {
|
||||
_drag_strength = strength * 5;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
} else {
|
||||
_drag_strength = 0;
|
||||
_drag_timer.stop();
|
||||
if ((_measure_type != LOGIC_MOVE && _measure_type != LOGIC_CURS) &&
|
||||
_view.session().get_device()->dev_inst()->mode == LOGIC &&
|
||||
_mouse_down_point.x() == event->pos().x() &&
|
||||
event->button() & Qt::LeftButton) {
|
||||
if (_measure_type == LOGIC_EDGE) {
|
||||
_measure_type = NO_MEASURE;
|
||||
_measure_shown = false;
|
||||
_edge_rising = 0;
|
||||
_edge_falling = 0;
|
||||
} else {
|
||||
_measure_type = LOGIC_EDGE;
|
||||
_edge_start = (_view.offset() + (event->pos().x() + 0.5) * _view.scale()) * _view.session().get_device()->get_sample_rate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_view.session().get_device()->dev_inst()->mode == LOGIC &&
|
||||
(_measure_type == NO_MEASURE || _measure_type == LOGIC_MOVE)) {
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_time.elapsed();
|
||||
if (_time.elapsed() < 200 &&
|
||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||
abs(strength) > MinorDragRateUp) {
|
||||
_drag_strength = _drag_strength;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
_measure_type = LOGIC_MOVE;
|
||||
} else if (_time.elapsed() < 200 &&
|
||||
abs(strength) > DragTimerInterval) {
|
||||
_drag_strength = strength * 5;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
_measure_type = LOGIC_MOVE;
|
||||
} else {
|
||||
_drag_strength = 0;
|
||||
_drag_timer.stop();
|
||||
_measure_type = NO_MEASURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_view.get_ruler()->get_grabbed_cursor() && _measure_type == LOGIC_CURS)
|
||||
_measure_type = NO_MEASURE;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -532,14 +573,20 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
(void)event;
|
||||
|
||||
if (_view.session().get_device()->dev_inst()->mode == LOGIC) {
|
||||
if (_view.scale() == _view.get_maxscale())
|
||||
_view.set_preScale_preOffset();
|
||||
else
|
||||
_view.set_scale_offset(_view.get_maxscale(), 0);
|
||||
|
||||
if (event->button() & Qt::RightButton) {
|
||||
if (_view.scale() == _view.get_maxscale())
|
||||
_view.set_preScale_preOffset();
|
||||
else
|
||||
_view.set_scale_offset(_view.get_maxscale(), 0);
|
||||
} else if (event->button() & Qt::LeftButton) {
|
||||
uint64_t index = (_view.offset() + (event->pos().x() + 0.5) * _view.scale()) * _view.session().get_device()->get_sample_rate();
|
||||
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
|
||||
_view.show_cursors(true);
|
||||
}
|
||||
update();
|
||||
} else if (_view.session().get_device()->dev_inst()->mode == DSO &&
|
||||
_view.session().get_capture_state() != SigSession::Init) {
|
||||
_view.session().get_capture_state() != SigSession::Init &&
|
||||
event->button() & Qt::LeftButton) {
|
||||
if (_dso_xm_stage == 0) {
|
||||
uint64_t sample_rate = _view.session().get_device()->get_sample_rate();
|
||||
double scale = _view.scale();
|
||||
@@ -587,6 +634,10 @@ void Viewport::leaveEvent(QEvent *)
|
||||
_measure_shown = _dso_xm || _dso_ym;
|
||||
_mouse_point = QPoint(-1, -1);
|
||||
//_view.show_cursors(false);
|
||||
if (_measure_type == LOGIC_EDGE || _measure_type == LOGIC_MOVE) {
|
||||
_measure_type = NO_MEASURE;
|
||||
_measure_shown = false;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -610,52 +661,74 @@ void Viewport::set_receive_len(quint64 length)
|
||||
update();
|
||||
}
|
||||
|
||||
void Viewport::clear_measure()
|
||||
{
|
||||
_measure_type = NO_MEASURE;
|
||||
update();
|
||||
}
|
||||
|
||||
void Viewport::measure()
|
||||
{
|
||||
if ((_view.session().get_device()->dev_inst()->mode == LOGIC &&
|
||||
_view.session().get_capture_state() == SigSession::Running) ||
|
||||
_drag_strength != 0)
|
||||
return;
|
||||
_measure_shown = _dso_xm || _dso_ym;
|
||||
const uint64_t sample_rate = _view.session().get_device()->get_sample_rate();
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
|
||||
if (logicSig->measure(_view.hover_point(), _cur_sample, _nxt_sample, _thd_sample)) {
|
||||
_measure_shown = true;
|
||||
_measure_type = LOGIC_FREQ;
|
||||
_measure_shown = _dso_xm || _dso_ym;
|
||||
const uint64_t sample_rate = _view.session().get_device()->get_sample_rate();
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
boost::shared_ptr<view::LogicSignal> logicSig;
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
|
||||
if (_measure_type != LOGIC_EDGE &&
|
||||
logicSig->measure(_view.hover_point(), _cur_sample, _nxt_sample, _thd_sample)) {
|
||||
_measure_shown = true;
|
||||
_measure_type = LOGIC_FREQ;
|
||||
|
||||
_mm_width = _view.get_ruler()->format_real_time(_nxt_sample - _cur_sample, sample_rate);
|
||||
_mm_period = _thd_sample != 0 ? _view.get_ruler()->format_real_time(_thd_sample - _cur_sample, sample_rate) : "#####";
|
||||
_mm_freq = _thd_sample != 0 ? _view.get_ruler()->format_real_freq(_thd_sample - _cur_sample, sample_rate) : "#####";
|
||||
_mm_width = _view.get_ruler()->format_real_time(_nxt_sample - _cur_sample, sample_rate);
|
||||
_mm_period = _thd_sample != 0 ? _view.get_ruler()->format_real_time(_thd_sample - _cur_sample, sample_rate) : "#####";
|
||||
_mm_freq = _thd_sample != 0 ? _view.get_ruler()->format_real_freq(_thd_sample - _cur_sample, sample_rate) : "#####";
|
||||
|
||||
const double pixels_offset = _view.offset() / _view.scale();
|
||||
const double samples_per_pixel = sample_rate * _view.scale();
|
||||
_cur_preX = _cur_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_aftX = _nxt_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_thdX = _thd_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_midY = logicSig->get_y();
|
||||
const double pixels_offset = _view.offset() / _view.scale();
|
||||
const double samples_per_pixel = sample_rate * _view.scale();
|
||||
_cur_preX = _cur_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_aftX = _nxt_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_thdX = _thd_sample / samples_per_pixel - pixels_offset;
|
||||
_cur_midY = logicSig->get_y();
|
||||
|
||||
_mm_duty = _thd_sample != 0 ? QString::number((_nxt_sample - _cur_sample) * 100.0 / (_thd_sample - _cur_sample), 'f', 2)+"%" :
|
||||
_mm_duty = _thd_sample != 0 ? QString::number((_nxt_sample - _cur_sample) * 100.0 / (_thd_sample - _cur_sample), 'f', 2)+"%" :
|
||||
"#####";
|
||||
mouse_measure();
|
||||
break;
|
||||
} else {
|
||||
_mm_width = "#####";
|
||||
_mm_period = "#####";
|
||||
_mm_freq = "#####";
|
||||
_mm_duty = "#####";
|
||||
}
|
||||
mouse_measure();
|
||||
} else if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
if (_measure_en && dsoSig->measure(_view.hover_point())) {
|
||||
_measure_shown = true;
|
||||
_measure_type = DSO_FREQ;
|
||||
}
|
||||
}
|
||||
mouse_measure();
|
||||
break;
|
||||
} else if (_measure_type == LOGIC_EDGE &&
|
||||
logicSig->edges(_view.hover_point(), _edge_start, _edge_rising, _edge_falling)) {
|
||||
_measure_shown = true;
|
||||
|
||||
const double pixels_offset = _view.offset() / _view.scale();
|
||||
const double samples_per_pixel = sample_rate * _view.scale();
|
||||
_cur_preX = _edge_start / samples_per_pixel - pixels_offset;
|
||||
_cur_aftX = _view.hover_point().x();
|
||||
_cur_midY = logicSig->get_y() - logicSig->get_signalHeight()/2 - 5;
|
||||
|
||||
_em_rising = "Rising: " + QString::number(_edge_rising);
|
||||
_em_falling = "Falling: " + QString::number(_edge_falling);
|
||||
_em_edges = "Edges: " + QString::number(_edge_rising + _edge_falling);
|
||||
|
||||
break;
|
||||
} else {
|
||||
_mm_width = "#####";
|
||||
_mm_period = "#####";
|
||||
_mm_freq = "#####";
|
||||
_mm_duty = "#####";
|
||||
}
|
||||
mouse_measure();
|
||||
} else if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
|
||||
if (_measure_en && dsoSig->measure(_view.hover_point())) {
|
||||
_measure_shown = true;
|
||||
_measure_type = DSO_FREQ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,6 +788,43 @@ void Viewport::paintMeasure(QPainter &p)
|
||||
p.drawText(measure4_rect, Qt::AlignRight | Qt::AlignVCenter,
|
||||
tr("Duty Cycle: ") + _mm_duty);
|
||||
}
|
||||
} else if (_measure_type == LOGIC_EDGE) {
|
||||
p.setPen(QColor(17, 133, 209, 255));
|
||||
|
||||
p.drawLine(QLineF(_cur_preX, _cur_midY-5, _cur_preX, _cur_midY+5));
|
||||
p.drawLine(QLineF(_cur_aftX, _cur_midY-5, _cur_aftX, _cur_midY+5));
|
||||
p.drawLine(QLineF(_cur_preX, _cur_midY, _cur_aftX, _cur_midY));
|
||||
|
||||
int typical_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
|
||||
Qt::AlignLeft | Qt::AlignTop, _em_edges).width();
|
||||
typical_width = max(typical_width, p.boundingRect(0, 0, INT_MAX, INT_MAX,
|
||||
Qt::AlignLeft | Qt::AlignTop, _em_rising).width());
|
||||
typical_width = max(typical_width, p.boundingRect(0, 0, INT_MAX, INT_MAX,
|
||||
Qt::AlignLeft | Qt::AlignTop, _em_falling).width());
|
||||
|
||||
typical_width = typical_width + 30;
|
||||
|
||||
const double width = _view.get_view_width();
|
||||
const double height = _view.viewport()->height();
|
||||
const double left = _view.hover_point().x();
|
||||
const double top = _view.hover_point().y();
|
||||
const double right = left + typical_width;
|
||||
const double bottom = top + 60;
|
||||
QPointF org_pos = QPointF(right > width ? left - typical_width : left, bottom > height ? top - 80 : top);
|
||||
QRectF measure_rect = QRectF(org_pos.x(), org_pos.y(), (double)typical_width, 60.0);
|
||||
QRectF measure1_rect = QRectF(org_pos.x(), org_pos.y(), (double)typical_width, 20.0);
|
||||
QRectF measure2_rect = QRectF(org_pos.x(), org_pos.y()+20, (double)typical_width, 20.0);
|
||||
QRectF measure3_rect = QRectF(org_pos.x(), org_pos.y()+40, (double)typical_width, 20.0);
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(QColor(17, 133, 209, 150));
|
||||
p.drawRect(measure_rect);
|
||||
|
||||
p.setPen(Qt::black);
|
||||
p.drawText(measure1_rect, Qt::AlignRight | Qt::AlignVCenter, _em_edges);
|
||||
p.drawText(measure2_rect, Qt::AlignRight | Qt::AlignVCenter, _em_rising);
|
||||
p.drawText(measure3_rect, Qt::AlignRight | Qt::AlignVCenter, _em_falling);
|
||||
|
||||
} else if (_measure_type == DSO_FREQ) {
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
enum MeasureType {
|
||||
NO_MEASURE,
|
||||
LOGIC_FREQ,
|
||||
LOGIC_EDGE,
|
||||
LOGIC_MOVE,
|
||||
LOGIC_CURS,
|
||||
DSO_FREQ
|
||||
};
|
||||
|
||||
@@ -74,6 +77,8 @@ public:
|
||||
void start_trigger_timer(int msec);
|
||||
void stop_trigger_timer();
|
||||
|
||||
void clear_measure();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
@@ -118,7 +123,7 @@ private:
|
||||
|
||||
bool _measure_en;
|
||||
bool _measure_shown;
|
||||
int _measure_type;
|
||||
MeasureType _measure_type;
|
||||
uint64_t _cur_sample;
|
||||
uint64_t _nxt_sample;
|
||||
uint64_t _thd_sample;
|
||||
@@ -131,6 +136,13 @@ private:
|
||||
QString _mm_freq;
|
||||
QString _mm_duty;
|
||||
|
||||
uint64_t _edge_rising;
|
||||
uint64_t _edge_falling;
|
||||
uint64_t _edge_start;
|
||||
QString _em_rising;
|
||||
QString _em_falling;
|
||||
QString _em_edges;
|
||||
|
||||
QTimer trigger_timer;
|
||||
bool triggered;
|
||||
int timer_cnt;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace widgets {
|
||||
DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_layout(new QGridLayout),
|
||||
_show_hide_button(QIcon(":/icons/decoder-shown.png"), QString(), this)
|
||||
_show_hide_button(QIcon(":/icons/shown.png"), QString(), this)
|
||||
{
|
||||
_layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(_layout);
|
||||
@@ -61,8 +61,8 @@ void DecoderGroupBox::add_layout(QLayout *layout)
|
||||
void DecoderGroupBox::set_decoder_visible(bool visible)
|
||||
{
|
||||
_show_hide_button.setIcon(QIcon(visible ?
|
||||
":/icons/decoder-shown.png" :
|
||||
":/icons/decoder-hidden.png"));
|
||||
":/icons/shown.png" :
|
||||
":/icons/hidden.png"));
|
||||
}
|
||||
|
||||
} // widgets
|
||||
|
||||