forked from Ivasoft/DSView
code format
This commit is contained in:
@@ -87,7 +87,8 @@ void LogicSnapshot::init()
|
|||||||
|
|
||||||
void LogicSnapshot::init_all()
|
void LogicSnapshot::init_all()
|
||||||
{
|
{
|
||||||
_sample_count = 0;
|
_sample_count = 0;
|
||||||
|
_real_sample_count = 0;
|
||||||
_ring_sample_count = 0;
|
_ring_sample_count = 0;
|
||||||
_block_num = 0;
|
_block_num = 0;
|
||||||
_byte_fraction = 0;
|
_byte_fraction = 0;
|
||||||
@@ -244,15 +245,17 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
|||||||
|
|
||||||
void *src_data_ptr = logic.data;
|
void *src_data_ptr = logic.data;
|
||||||
uint64_t data_len = logic.length;
|
uint64_t data_len = logic.length;
|
||||||
|
|
||||||
// samples not accurate, lead to a larger _sampole_count
|
// samples not accurate, lead to a larger _sampole_count
|
||||||
// _sample_count should be fixed in the last packet
|
// _sample_count should be fixed in the last packet
|
||||||
// so _total_sample_count must be align to LeafBlock
|
// so _total_sample_count must be align to LeafBlock
|
||||||
uint64_t sample_num = ceil(data_len * 8.0 / _channel_num);
|
uint64_t sample_num = ceil(data_len * 8.0 / _channel_num);
|
||||||
|
|
||||||
if (_sample_count + sample_num < _total_sample_count)
|
if (_sample_count + sample_num < _total_sample_count)
|
||||||
_sample_count += sample_num;
|
_sample_count += sample_num;
|
||||||
else
|
else
|
||||||
_sample_count = _total_sample_count;
|
_sample_count = _total_sample_count;
|
||||||
|
|
||||||
while (_sample_count > _block_num * LeafBlockSamples) {
|
while (_sample_count > _block_num * LeafBlockSamples) {
|
||||||
uint8_t index0 = _block_num / RootScale;
|
uint8_t index0 = _block_num / RootScale;
|
||||||
uint8_t index1 = _block_num % RootScale;
|
uint8_t index1 = _block_num % RootScale;
|
||||||
@@ -280,6 +283,10 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
|||||||
uint8_t *dp_tmp = (uint8_t *)_dest_ptr;
|
uint8_t *dp_tmp = (uint8_t *)_dest_ptr;
|
||||||
uint8_t *sp_tmp = (uint8_t *)src_data_ptr;
|
uint8_t *sp_tmp = (uint8_t *)src_data_ptr;
|
||||||
|
|
||||||
|
if (_dest_ptr == NULL){
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
*dp_tmp++ = *sp_tmp++;
|
*dp_tmp++ = *sp_tmp++;
|
||||||
_byte_fraction = (_byte_fraction + 1) % ScaleSize;
|
_byte_fraction = (_byte_fraction + 1) % ScaleSize;
|
||||||
@@ -316,7 +323,6 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
|||||||
int order = 0;
|
int order = 0;
|
||||||
const uint64_t align_size = data_len / ScaleSize / _channel_num;
|
const uint64_t align_size = data_len / ScaleSize / _channel_num;
|
||||||
_ring_sample_count += align_size * Scale;
|
_ring_sample_count += align_size * Scale;
|
||||||
|
|
||||||
|
|
||||||
for(auto& iter : _ch_data) {
|
for(auto& iter : _ch_data) {
|
||||||
uint64_t index0 = pre_index0;
|
uint64_t index0 = pre_index0;
|
||||||
@@ -337,9 +343,11 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
|||||||
// calc root of current block
|
// calc root of current block
|
||||||
if (*((uint64_t *)iter[index0].lbp[index1]) != 0)
|
if (*((uint64_t *)iter[index0].lbp[index1]) != 0)
|
||||||
iter[index0].value += 1ULL<< index1;
|
iter[index0].value += 1ULL<< index1;
|
||||||
|
|
||||||
if (*((uint64_t *)iter[index0].lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) {
|
if (*((uint64_t *)iter[index0].lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) {
|
||||||
iter[index0].tog += 1ULL << index1;
|
iter[index0].tog += 1ULL << index1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// trim leaf to free space
|
// trim leaf to free space
|
||||||
free(iter[index0].lbp[index1]);
|
free(iter[index0].lbp[index1]);
|
||||||
iter[index0].lbp[index1] = NULL;
|
iter[index0].lbp[index1] = NULL;
|
||||||
@@ -379,6 +387,8 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
|||||||
}
|
}
|
||||||
_dest_ptr = dp_tmp + _byte_fraction;
|
_dest_ptr = dp_tmp + _byte_fraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_real_sample_count = _sample_count / RootNodeSamples * RootNodeSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic)
|
void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic)
|
||||||
@@ -455,7 +465,7 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples)
|
void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples)
|
||||||
{
|
{
|
||||||
uint8_t offset;
|
uint8_t offset;
|
||||||
uint64_t *src_ptr;
|
uint64_t *src_ptr;
|
||||||
uint64_t *dest_ptr;
|
uint64_t *dest_ptr;
|
||||||
@@ -557,6 +567,7 @@ bool LogicSnapshot::get_display_edges(std::vector<std::pair<bool, bool> > &edges
|
|||||||
// Get the initial state
|
// Get the initial state
|
||||||
start_sample = last_sample = get_sample(index++, sig_index);
|
start_sample = last_sample = get_sample(index++, sig_index);
|
||||||
togs.push_back(pair<uint16_t, bool>(0, last_sample));
|
togs.push_back(pair<uint16_t, bool>(0, last_sample));
|
||||||
|
|
||||||
while(edges.size() < width) {
|
while(edges.size() < width) {
|
||||||
// search next edge
|
// search next edge
|
||||||
bool has_edge = get_nxt_edge(index, last_sample, end, 0, sig_index);
|
bool has_edge = get_nxt_edge(index, last_sample, end, 0, sig_index);
|
||||||
@@ -564,8 +575,10 @@ bool LogicSnapshot::get_display_edges(std::vector<std::pair<bool, bool> > &edges
|
|||||||
// calc the edge position
|
// calc the edge position
|
||||||
int64_t gap = (index / min_length) - pixels_offset;
|
int64_t gap = (index / min_length) - pixels_offset;
|
||||||
index = max((uint64_t)ceil((floor(index/min_length) + 1) * min_length), index + 1);
|
index = max((uint64_t)ceil((floor(index/min_length) + 1) * min_length), index + 1);
|
||||||
while(gap > (int64_t)edges.size() && edges.size() < width)
|
|
||||||
|
while(gap > (int64_t)edges.size() && edges.size() < width){
|
||||||
edges.push_back(pair<bool, bool>(false, last_sample));
|
edges.push_back(pair<bool, bool>(false, last_sample));
|
||||||
|
}
|
||||||
|
|
||||||
if (index > end)
|
if (index > end)
|
||||||
last_sample = get_sample(end, sig_index);
|
last_sample = get_sample(end, sig_index);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ Snapshot::Snapshot(int unit_size, uint64_t total_sample_count, unsigned int chan
|
|||||||
_unit_bytes = 1;
|
_unit_bytes = 1;
|
||||||
_unit_pitch = 0;
|
_unit_pitch = 0;
|
||||||
_have_data = false;
|
_have_data = false;
|
||||||
|
_real_sample_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Snapshot::~Snapshot()
|
Snapshot::~Snapshot()
|
||||||
@@ -58,6 +59,7 @@ void Snapshot::free_data()
|
|||||||
_data = NULL;
|
_data = NULL;
|
||||||
_capacity = 0;
|
_capacity = 0;
|
||||||
_sample_count = 0;
|
_sample_count = 0;
|
||||||
|
_real_sample_count = 0;
|
||||||
}
|
}
|
||||||
_ch_index.clear();
|
_ch_index.clear();
|
||||||
}
|
}
|
||||||
@@ -73,7 +75,13 @@ bool Snapshot::empty()
|
|||||||
uint64_t Snapshot::get_sample_count()
|
uint64_t Snapshot::get_sample_count()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
return _sample_count;
|
//return _sample_count;
|
||||||
|
// /*
|
||||||
|
if (_real_sample_count > 0)
|
||||||
|
return _real_sample_count;
|
||||||
|
else
|
||||||
|
return _sample_count;
|
||||||
|
// */
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Snapshot::get_ring_start()
|
uint64_t Snapshot::get_ring_start()
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ protected:
|
|||||||
uint64_t _capacity;
|
uint64_t _capacity;
|
||||||
unsigned int _channel_num;
|
unsigned int _channel_num;
|
||||||
uint64_t _sample_count;
|
uint64_t _sample_count;
|
||||||
|
uint64_t _real_sample_count;
|
||||||
uint64_t _total_sample_count;
|
uint64_t _total_sample_count;
|
||||||
uint64_t _ring_sample_count;
|
uint64_t _ring_sample_count;
|
||||||
int _unit_size;
|
int _unit_size;
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
|
|||||||
int preY = first_sample ? high_offset : low_offset;
|
int preY = first_sample ? high_offset : low_offset;
|
||||||
int x = preX;
|
int x = preX;
|
||||||
std::vector<QLine> wave_lines;
|
std::vector<QLine> wave_lines;
|
||||||
|
|
||||||
if (_cur_edges.size() < max_togs) {
|
if (_cur_edges.size() < max_togs) {
|
||||||
std::vector<std::pair<uint16_t, bool>>::const_iterator i;
|
std::vector<std::pair<uint16_t, bool>>::const_iterator i;
|
||||||
for (i = _cur_edges.begin() + 1; i != _cur_edges.end() - 1; i++) {
|
for (i = _cur_edges.begin() + 1; i != _cur_edges.end() - 1; i++) {
|
||||||
@@ -181,7 +182,8 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
|
|||||||
}
|
}
|
||||||
x = (*i).first;
|
x = (*i).first;
|
||||||
wave_lines.push_back(QLine(preX, preY, x, preY));
|
wave_lines.push_back(QLine(preX, preY, x, preY));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
std::vector<std::pair<bool, bool>>::const_iterator i = _cur_pulses.begin();
|
std::vector<std::pair<bool, bool>>::const_iterator i = _cur_pulses.begin();
|
||||||
while (i != _cur_pulses.end() - 1) {
|
while (i != _cur_pulses.end() - 1) {
|
||||||
if ((*i).first) {
|
if ((*i).first) {
|
||||||
|
|||||||
@@ -166,7 +166,8 @@ void Viewport::paintEvent(QPaintEvent *event)
|
|||||||
if (_view.session().get_device()->get_work_mode() == LOGIC ||
|
if (_view.session().get_device()->get_work_mode() == LOGIC ||
|
||||||
_view.session().is_instant())
|
_view.session().is_instant())
|
||||||
{
|
{
|
||||||
if (_view.session().is_stopped_status())// || _view.session().is_realtime_mode()){
|
if (_view.session().is_stopped_status()
|
||||||
|
|| _view.session().is_realtime_mode())
|
||||||
{
|
{
|
||||||
paintSignals(p, fore, back);
|
paintSignals(p, fore, back);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user