2
0
forked from Ivasoft/DSView

On real-time mode, auto set the max scale when start capture data

This commit is contained in:
dreamsourcelabTAI
2022-12-21 11:47:07 +08:00
parent 52298c1024
commit 21799ffe00
5 changed files with 179 additions and 204 deletions

View File

@@ -234,6 +234,8 @@ namespace pv
retranslateUi();
_sampling_bar->set_view(_view);
// event
connect(&_event, SIGNAL(session_error()), this, SLOT(on_session_error()));
connect(&_event, SIGNAL(signals_changed()), this, SLOT(on_signals_changed()));

View File

@@ -37,6 +37,7 @@
#include "../deviceagent.h"
#include "../ui/msgbox.h"
#include "../ui/langresource.h"
#include "../view/view.h"
using std::map;
using std::max;
@@ -69,6 +70,7 @@ namespace pv
_last_device_handle = NULL_HANDLE;
_last_device_index = -1;
_next_switch_device = NULL_HANDLE;
_view = NULL;
_session = session;
_device_agent = _session->get_device();
@@ -882,6 +884,11 @@ namespace pv
}
}
if (_device_agent->get_work_mode() == LOGIC && _session->is_realtime_mode()){
if (_view != NULL)
_view->auto_set_max_scale();
}
_is_run_as_instant = false;
_session->start_capture(false);
}
@@ -892,8 +899,7 @@ namespace pv
{
bool wait_upload = false;
if (_session->is_repeat_mode() == false)
{
if (_session->is_repeat_mode() == false){
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
if (gvar != NULL)
{
@@ -901,57 +907,62 @@ namespace pv
g_variant_unref(gvar);
}
}
if (!wait_upload)
{
if (!wait_upload){
_session->stop_capture();
}
return;
}
else
if (_device_agent->have_instance() == false)
{
if (_device_agent->have_instance() == false)
dsv_info("%s", "Error! Have no device, can't to collect data.");
return;
}
commit_settings();
if (_device_agent->get_work_mode() == DSO)
{
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL)
{
dsv_info("%s", "Error! Have no device, can't to collect data.");
return;
}
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
commit_settings();
if (_device_agent->get_work_mode() == DSO)
{
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL)
if (zero)
{
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_A_CAL), "Auto Calibration"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_A_CAL_START), "Auto Calibration program will be started. Don't connect any probes. It can take a while!"));
if (zero)
msg.mBox()->addButton(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_OK), "Ok"), QMessageBox::AcceptRole);
msg.mBox()->addButton(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_SKIP), "Skip"), QMessageBox::RejectRole);
msg.mBox()->setIcon(QMessageBox::Warning);
if (msg.exec())
{
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_A_CAL), "Auto Calibration"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_A_CAL_START), "Auto Calibration program will be started. Don't connect any probes. It can take a while!"));
msg.mBox()->addButton(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_OK), "Ok"), QMessageBox::AcceptRole);
msg.mBox()->addButton(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_SKIP), "Skip"), QMessageBox::RejectRole);
msg.mBox()->setIcon(QMessageBox::Warning);
if (msg.exec())
{
zero_adj();
}
else
{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
update_view_status();
}
return;
zero_adj();
}
else
{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
update_view_status();
}
return;
}
}
_is_run_as_instant = true;
_session->start_capture(true);
}
if (_device_agent->get_work_mode() == LOGIC && _session->is_realtime_mode()){
if (_view != NULL)
_view->auto_set_max_scale();
}
_is_run_as_instant = true;
_session->start_capture(true);
}
void SamplingBar::on_device_selected()

View File

@@ -48,7 +48,11 @@ namespace pv
namespace device
{
class DevInst;
}
}
namespace view{
class View;
}
namespace dialogs
{
@@ -87,6 +91,10 @@ namespace pv
ds_device_handle get_next_device_handle();
void update_sample_rate_selector();
inline void set_view(view::View *view){
_view = view;
}
signals:
void sig_store_session_data();
@@ -145,8 +153,8 @@ namespace pv
ds_device_handle _last_device_handle;
ds_device_handle _next_switch_device;
int _last_device_index;
bool _is_run_as_instant;
view::View *_view;
};
} // namespace toolbars

View File

@@ -47,6 +47,7 @@
#include "../dialogs/calibration.h"
#include "../dialogs/lissajousoptions.h"
#include "../dsvdef.h"
#include "../log.h"
using namespace std;
@@ -207,41 +208,6 @@ void View::set_device()
_devmode->set_device();
}
SigSession& View::session()
{
return *_session;
}
double View::scale()
{
return _scale;
}
int64_t View::offset()
{
return _offset;
}
double View::trig_hoff()
{
return _trig_hoff;
}
void View::set_trig_hoff(double hoff)
{
_trig_hoff = hoff;
}
double View::get_minscale()
{
return _minscale;
}
double View::get_maxscale()
{
return _maxscale;
}
void View::capture_init()
{
int mode = _device_agent->get_work_mode();
@@ -425,21 +391,6 @@ bool View::compare_trace_v_offsets(const Trace *a,
return a1->get_v_offset() < b1->get_v_offset();
}
bool View::cursors_shown()
{
return _show_cursors;
}
bool View::trig_cursor_shown()
{
return _show_trig_cursor;
}
bool View::search_cursor_shown()
{
return _show_search_cursor;
}
void View::show_cursors(bool show)
{
_show_cursors = show;
@@ -550,21 +501,6 @@ void View::set_search_pos(uint64_t search_pos, bool hit)
}
}
uint64_t View::get_search_pos()
{
return _search_pos;
}
bool View::get_search_hit()
{
return _search_hit;
}
const QPoint& View::hover_point()
{
return _hover_point;
}
void View::normalize_layout()
{
int v_min = INT_MAX;
@@ -585,16 +521,6 @@ void View::normalize_layout()
v_scroll_value_changed(verticalScrollBar()->sliderPosition());
}
int View::get_spanY()
{
return _spanY;
}
int View::get_signalHeight()
{
return _signalHeight;
}
void View::get_scroll_layout(int64_t &length, int64_t &offset)
{
const auto data_set = _session->get_data();
@@ -961,29 +887,6 @@ void View::on_traces_moved()
viewport_update();
}
/*
* cursorList
*/
std::list<Cursor*>& View::get_cursorList()
{
return _cursorList;
}
Cursor* View::get_trig_cursor()
{
return _trig_cursor;
}
Cursor* View::get_search_cursor()
{
return _search_cursor;
}
Ruler* View::get_ruler()
{
return _ruler;
}
void View::add_cursor(QColor color, uint64_t index)
{
Cursor *newCursor = new Cursor(*this, color, index);
@@ -1258,24 +1161,6 @@ bool View::get_dso_trig_moved()
return _time_viewport->get_dso_trig_moved();
}
/*
* horizental cursors
*/
bool View::xcursors_shown()
{
return _show_xcursors;
}
void View::show_xcursors(bool show)
{
_show_xcursors = show;
}
std::list<XCursor*>& View::get_xcursorList()
{
return _xcursorList;
}
void View::add_xcursor(QColor color, double value0, double value1)
{
XCursor *newXCursor = new XCursor(*this, color, value0, value1);
@@ -1292,21 +1177,6 @@ void View::del_xcursor(XCursor* xcursor)
xcursor_update();
}
ViewStatus* View::get_viewstatus()
{
return _viewbottom;
}
bool View::back_ready()
{
return _back_ready;
}
void View::set_back(bool ready)
{
_back_ready = ready;
}
double View::index2pixel(uint64_t index, bool has_hoff)
{
const double samples_per_pixel = session().cur_snap_samplerate() * scale();
@@ -1362,5 +1232,28 @@ void View::check_calibration()
}
}
void View::set_scale(double scale)
{
if (scale < _minscale)
scale = _minscale;
if (scale > _maxscale)
scale = _maxscale;
if (_scale != scale)
{
_scale = scale;
_header->update();
_ruler->update();
viewport_update();
update_scroll();
}
}
void View::auto_set_max_scale()
{
_maxscale = _session->cur_sampletime() / (get_view_width() * MaxViewRate);
set_scale(_maxscale);
}
} // namespace view
} // namespace pv

View File

@@ -109,24 +109,46 @@ public:
~View();
SigSession& session();
inline SigSession& session(){
return *_session;
}
/**
* Returns the view time scale in seconds per pixel.
*/
double scale();
inline double scale(){
return _scale;
}
inline double get_minscale(){
return _minscale;
}
inline double get_maxscale(){
return _maxscale;
}
void set_scale(double scale);
void auto_set_max_scale();
/**
* Returns the pixels offset of the left edge of the view
*/
int64_t offset();
int v_offset();
inline int64_t offset(){
return _offset;
}
/**
* trigger position fix
*/
double trig_hoff();
void set_trig_hoff(double hoff);
inline double trig_hoff(){
return _trig_hoff;
}
inline void set_trig_hoff(double hoff){
_trig_hoff = hoff;
}
int64_t get_min_offset();
int64_t get_max_offset();
@@ -149,24 +171,40 @@ public:
/**
* Returns true if cursors are displayed. false otherwise.
*/
bool cursors_shown();
bool trig_cursor_shown();
bool search_cursor_shown();
inline bool cursors_shown(){
return _show_cursors;
}
int get_spanY();
inline bool trig_cursor_shown(){
return _show_trig_cursor;
}
int get_signalHeight();
inline bool search_cursor_shown(){
return _show_search_cursor;
}
inline int get_spanY(){
return _spanY;
}
inline int get_signalHeight(){
return _signalHeight;
}
int headerWidth();
Ruler* get_ruler();
inline Ruler* get_ruler(){
return _ruler;
}
/**
* Shows or hides the cursors.
*/
void show_cursors(bool show = true);
const QPoint& hover_point();
inline const QPoint& hover_point(){
return _hover_point;
}
void normalize_layout();
@@ -177,35 +215,51 @@ public:
/*
* cursorList
*/
std::list<Cursor*>& get_cursorList();
inline std::list<Cursor*>& get_cursorList(){
return _cursorList;
}
void add_cursor(QColor color, uint64_t index);
void del_cursor(Cursor* cursor);
void clear_cursors();
void set_cursor_middle(int index);
Cursor* get_trig_cursor();
Cursor* get_search_cursor();
bool get_search_hit();
inline Cursor* get_trig_cursor(){
return _trig_cursor;
}
inline Cursor* get_search_cursor(){
return _search_cursor;
}
inline bool get_search_hit(){
return _search_hit;
}
void set_search_pos(uint64_t search_pos, bool hit);
uint64_t get_search_pos();
inline uint64_t get_search_pos(){
return _search_pos;
}
/*
* horizental cursors
*/
bool xcursors_shown();
void show_xcursors(bool show);
std::list<XCursor*>& get_xcursorList();
inline bool xcursors_shown(){
return _show_xcursors;
}
inline void show_xcursors(bool show){
_show_xcursors = show;
}
inline std::list<XCursor*>& get_xcursorList(){
return _xcursorList;
}
void add_xcursor(QColor color, double value0, double value1);
void del_xcursor(XCursor* xcursor);
/*
*
*/
double get_minscale();
double get_maxscale();
void set_update(Viewport *viewport, bool need_update);
void set_all_update(bool need_update);
@@ -230,13 +284,20 @@ public:
bool get_dso_trig_moved();
ViewStatus* get_viewstatus();
inline ViewStatus* get_viewstatus(){
return _viewbottom;
}
/*
* back paint status
*/
bool back_ready();
void set_back(bool ready);
inline bool back_ready(){
return _back_ready;
}
inline void set_back(bool ready){
_back_ready = ready;
}
/*
* untils