pv/session.hpp
pv/storesession.hpp
pv/binding/device.hpp
+ pv/data/analog.hpp
+ pv/data/analogsegment.hpp
+ pv/data/logic.hpp
+ pv/data/logicsegment.hpp
pv/data/signalbase.hpp
pv/dialogs/about.hpp
pv/dialogs/connect.hpp
void Analog::clear()
{
segments_.clear();
+
+ samples_cleared();
}
uint64_t Analog::max_sample_count() const
return l;
}
+void Analog::notify_samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample)
+{
+ samples_added(segment, start_sample, end_sample);
+}
+
} // namespace data
} // namespace pv
#include <deque>
#include <memory>
+#include <QObject>
+
namespace pv {
namespace data {
class AnalogSegment;
-class Analog : public SignalData
+class Analog : public QObject, public SignalData
{
+ Q_OBJECT
+
public:
Analog();
uint64_t max_sample_count() const;
+ void notify_samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample);
+
+Q_SIGNALS:
+ void samples_cleared();
+
+ void samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample);
+
private:
std::deque< std::shared_ptr<AnalogSegment> > segments_;
};
#include <algorithm>
+#include "analog.hpp"
#include "analogsegment.hpp"
using std::lock_guard;
logf(EnvelopeScaleFactor);
const uint64_t AnalogSegment::EnvelopeDataUnit = 64*1024; // bytes
-AnalogSegment::AnalogSegment(uint64_t samplerate) :
+AnalogSegment::AnalogSegment(Analog& owner, uint64_t samplerate) :
Segment(samplerate, sizeof(float)),
+ owner_(owner),
min_value_(0),
max_value_(0)
{
lock_guard<recursive_mutex> lock(mutex_);
+ uint64_t prev_sample_count = sample_count_;
+
for (uint32_t i=0; i < sample_count; i++) {
append_single_sample((void*)data);
data += stride;
// Generate the first mip-map from the data
append_payload_to_envelope_levels();
+
+ if (sample_count > 1)
+ owner_.notify_samples_added(this, prev_sample_count + 1,
+ prev_sample_count + 1 + sample_count);
+ else
+ owner_.notify_samples_added(this, prev_sample_count + 1,
+ prev_sample_count + 1);
}
const float* AnalogSegment::get_samples(
#include <utility>
#include <vector>
+#include <QObject>
+
namespace AnalogSegmentTest {
struct Basic;
}
namespace pv {
namespace data {
+class Analog;
+
typedef struct {
uint64_t sample_index, chunk_num, chunk_offs;
uint8_t* chunk;
float* value;
} SegmentAnalogDataIterator;
-class AnalogSegment : public Segment
+class AnalogSegment : public QObject, public Segment
{
+ Q_OBJECT
+
public:
struct EnvelopeSample
{
static const uint64_t EnvelopeDataUnit;
public:
- AnalogSegment(uint64_t samplerate);
+ AnalogSegment(Analog& owner, uint64_t samplerate);
virtual ~AnalogSegment();
void append_payload_to_envelope_levels();
private:
+ Analog& owner_;
+
struct Envelope envelope_levels_[ScaleStepCount];
float min_value_, max_value_;
void Logic::clear()
{
segments_.clear();
+
+ samples_cleared();
}
uint64_t Logic::max_sample_count() const
return l;
}
+void Logic::notify_samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample)
+{
+ samples_added(segment, start_sample, end_sample);
+}
+
} // namespace data
} // namespace pv
#include <deque>
+#include <QObject>
+
namespace pv {
namespace data {
class LogicSegment;
-class Logic : public SignalData
+class Logic : public QObject, public SignalData
{
+ Q_OBJECT
+
public:
Logic(unsigned int num_channels);
uint64_t max_sample_count() const;
+ void notify_samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample);
+
+Q_SIGNALS:
+ void samples_cleared();
+
+ void samples_added(QObject* segment, uint64_t start_sample,
+ uint64_t end_sample);
+
private:
const unsigned int num_channels_;
std::deque< std::shared_ptr<LogicSegment> > segments_;
#include <stdlib.h>
#include <cmath>
+#include "logic.hpp"
#include "logicsegment.hpp"
#include <libsigrokcxx/libsigrokcxx.hpp>
const float LogicSegment::LogMipMapScaleFactor = logf(MipMapScaleFactor);
const uint64_t LogicSegment::MipMapDataUnit = 64*1024; // bytes
-LogicSegment::LogicSegment(shared_ptr<Logic> logic, uint64_t samplerate) :
- Segment(samplerate, logic->unit_size()),
+LogicSegment::LogicSegment(pv::data::Logic& owner, shared_ptr<sigrok::Logic> data,
+ uint64_t samplerate) :
+ Segment(samplerate, data->unit_size()),
+ owner_(owner),
last_append_sample_(0)
{
lock_guard<recursive_mutex> lock(mutex_);
memset(mip_map_, 0, sizeof(mip_map_));
- append_payload(logic);
+ append_payload(data);
}
LogicSegment::~LogicSegment()
#endif
}
-void LogicSegment::append_payload(shared_ptr<Logic> logic)
+void LogicSegment::append_payload(shared_ptr<sigrok::Logic> logic)
{
assert(unit_size_ == logic->unit_size());
assert((logic->data_length() % unit_size_) == 0);
lock_guard<recursive_mutex> lock(mutex_);
- append_samples(logic->data_pointer(),
- logic->data_length() / unit_size_);
+ uint64_t prev_sample_count = sample_count_;
+ uint64_t sample_count = logic->data_length() / unit_size_;
+
+ append_samples(logic->data_pointer(), sample_count);
// Generate the first mip-map from the data
append_payload_to_mipmap();
+
+ if (sample_count > 1)
+ owner_.notify_samples_added(this, prev_sample_count + 1,
+ prev_sample_count + 1 + sample_count);
+ else
+ owner_.notify_samples_added(this, prev_sample_count + 1,
+ prev_sample_count + 1);
}
const uint8_t* LogicSegment::get_samples(int64_t start_sample,
#include <utility>
#include <vector>
+#include <QObject>
+
namespace sigrok {
class Logic;
}
namespace pv {
namespace data {
+class Logic;
+
typedef struct {
uint64_t sample_index, chunk_num, chunk_offs;
uint8_t* chunk;
uint8_t* value;
} SegmentLogicDataIterator;
-class LogicSegment : public Segment
+class LogicSegment : public QObject, public Segment
{
+ Q_OBJECT
+
private:
struct MipMapLevel
{
typedef std::pair<int64_t, bool> EdgePair;
public:
- LogicSegment(std::shared_ptr<sigrok::Logic> logic, uint64_t samplerate);
+ LogicSegment(pv::data::Logic& owner, std::shared_ptr<sigrok::Logic> data, uint64_t samplerate);
virtual ~LogicSegment();
static uint64_t pow2_ceil(uint64_t x, unsigned int power);
private:
+ Logic& owner_;
+
struct MipMapLevel mip_map_[ScaleStepCount];
uint64_t last_append_sample_;
// Create a new data segment
cur_logic_segment_ = shared_ptr<data::LogicSegment>(
- new data::LogicSegment(logic, cur_samplerate_));
+ new data::LogicSegment(*logic_data_, logic, cur_samplerate_));
logic_data_->push_segment(cur_logic_segment_);
// @todo Putting this here means that only listeners querying
// in the sweep containing this segment.
sweep_beginning = true;
- // Create a segment, keep it in the maps of channels
- segment = shared_ptr<data::AnalogSegment>(
- new data::AnalogSegment(cur_samplerate_));
- cur_analog_segments_[channel] = segment;
-
// Find the analog data associated with the channel
shared_ptr<data::SignalBase> base = signalbase_from_channel(channel);
assert(base);
shared_ptr<data::Analog> data(base->analog_data());
assert(data);
+ // Create a segment, keep it in the maps of channels
+ segment = shared_ptr<data::AnalogSegment>(
+ new data::AnalogSegment(*data, cur_samplerate_));
+ cur_analog_segments_[channel] = segment;
+
// Push the segment into the analog data.
data->push_segment(segment);
}