| 1579 | } |
| 1580 | |
| 1581 | void Viewport::measure() |
| 1582 | { |
| 1583 | if (_view.session().is_data_lock()) |
| 1584 | return; |
| 1585 | if (_view.session().is_loop_mode() && _view.session().is_working()) |
| 1586 | return; |
| 1587 | |
| 1588 | _measure_type = NO_MEASURE; |
| 1589 | |
| 1590 | if (_type == TIME_VIEW) { |
| 1591 | const uint64_t sample_rate = _view.session().cur_snap_samplerate(); |
| 1592 | |
| 1593 | for(auto s : _view.session().get_signals()) { |
| 1594 | if (s->signal_type() == SR_CHANNEL_LOGIC) { |
| 1595 | view::LogicSignal *logicSig = (view::LogicSignal*)s; |
| 1596 | |
| 1597 | if (_action_type == NO_ACTION) { |
| 1598 | if (logicSig->measure(_mouse_point, _cur_sample, _nxt_sample, _thd_sample)) { |
| 1599 | _measure_type = LOGIC_FREQ; |
| 1600 | |
| 1601 | _mm_width = _view.get_ruler()->format_real_time(_nxt_sample - _cur_sample, sample_rate); |
| 1602 | _mm_period = _thd_sample != 0 ? _view.get_ruler()->format_real_time(_thd_sample - _cur_sample, sample_rate) : View::Unknown_Str; |
| 1603 | _mm_freq = _thd_sample != 0 ? _view.get_ruler()->format_real_freq(_thd_sample - _cur_sample, sample_rate) : View::Unknown_Str; |
| 1604 | |
| 1605 | _cur_preX = _view.index2pixel(_cur_sample); |
| 1606 | _cur_aftX = _view.index2pixel(_nxt_sample); |
| 1607 | _cur_thdX = _view.index2pixel(_thd_sample); |
| 1608 | _cur_midY = logicSig->get_y(); |
| 1609 | |
| 1610 | _mm_duty = _thd_sample != 0 ? QString::number((_nxt_sample - _cur_sample) * 100.0 / (_thd_sample - _cur_sample), 'f', 2)+"%" : |
| 1611 | View::Unknown_Str; |
| 1612 | break; |
| 1613 | } |
| 1614 | else { |
| 1615 | _measure_type = NO_MEASURE; |
| 1616 | _mm_width = View::Unknown_Str; |
| 1617 | _mm_period = View::Unknown_Str; |
| 1618 | _mm_freq = View::Unknown_Str; |
| 1619 | _mm_duty = View::Unknown_Str; |
| 1620 | } |
| 1621 | } |
| 1622 | else if (_action_type == LOGIC_EDGE) { |
| 1623 | if (logicSig->edges(_view.hover_point(), _edge_start, _edge_rising, _edge_falling)) { |
| 1624 | _cur_preX = _view.index2pixel(_edge_start); |
| 1625 | _cur_aftX = _view.hover_point().x(); |
| 1626 | _cur_midY = logicSig->get_y() - logicSig->get_totalHeight()/2 - 5; |
| 1627 | |
| 1628 | _em_rising = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_RISING), "Rising: ") + QString::number(_edge_rising); |
| 1629 | _em_falling = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_FALLING), "Falling: ") + QString::number(_edge_falling); |
| 1630 | _em_edges = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_Edges_1), "Edges: ") + QString::number(_edge_rising + _edge_falling); |
| 1631 | |
| 1632 | break; |
| 1633 | } |
| 1634 | } |
| 1635 | else if (_action_type == LOGIC_JUMP) { |
| 1636 | if (logicSig->edge(_view.hover_point(), _edge_end, 10)) { |
| 1637 | _cur_aftX = _view.index2pixel(_edge_end); |
| 1638 | _cur_aftY = logicSig->get_y(); |
no test coverage detected