mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-13 13:32:53 +08:00
Merge branch 'dev-1.3'
This commit is contained in:
commit
83631c9d65
@ -31,9 +31,9 @@ set(DS_TITLE DSView)
|
|||||||
set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab")
|
set(DS_DESCRIPTION "A GUI for instruments of DreamSourceLab")
|
||||||
|
|
||||||
set(DS_VERSION_MAJOR 1)
|
set(DS_VERSION_MAJOR 1)
|
||||||
set(DS_VERSION_MINOR 2)
|
set(DS_VERSION_MINOR 3)
|
||||||
set(DS_VERSION_MICRO 1)
|
set(DS_VERSION_MICRO 0)
|
||||||
set(DS_VERSION_STRING ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO} )
|
set(DS_VERSION_STRING ${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}-dev )
|
||||||
|
|
||||||
configure_file (
|
configure_file (
|
||||||
${PROJECT_SOURCE_DIR}/DSView/config.h.in
|
${PROJECT_SOURCE_DIR}/DSView/config.h.in
|
||||||
@ -235,7 +235,6 @@ set(DSView_SOURCES
|
|||||||
DSView/pv/log.cpp
|
DSView/pv/log.cpp
|
||||||
DSView/pv/sigsession.cpp
|
DSView/pv/sigsession.cpp
|
||||||
DSView/pv/mainwindow.cpp
|
DSView/pv/mainwindow.cpp
|
||||||
DSView/pv/devicemanager.cpp
|
|
||||||
DSView/pv/data/snapshot.cpp
|
DSView/pv/data/snapshot.cpp
|
||||||
DSView/pv/data/signaldata.cpp
|
DSView/pv/data/signaldata.cpp
|
||||||
DSView/pv/data/logicsnapshot.cpp
|
DSView/pv/data/logicsnapshot.cpp
|
||||||
@ -290,14 +289,9 @@ set(DSView_SOURCES
|
|||||||
DSView/pv/widgets/decodermenu.cpp
|
DSView/pv/widgets/decodermenu.cpp
|
||||||
DSView/pv/widgets/decodergroupbox.cpp
|
DSView/pv/widgets/decodergroupbox.cpp
|
||||||
DSView/pv/prop/string.cpp
|
DSView/pv/prop/string.cpp
|
||||||
DSView/pv/device/sessionfile.cpp
|
|
||||||
DSView/pv/device/inputfile.cpp
|
|
||||||
DSView/pv/device/file.cpp
|
|
||||||
DSView/pv/device/devinst.cpp
|
|
||||||
DSView/pv/dialogs/storeprogress.cpp
|
DSView/pv/dialogs/storeprogress.cpp
|
||||||
DSView/pv/storesession.cpp
|
DSView/pv/storesession.cpp
|
||||||
DSView/pv/view/devmode.cpp
|
DSView/pv/view/devmode.cpp
|
||||||
DSView/pv/device/device.cpp
|
|
||||||
DSView/pv/dialogs/waitingdialog.cpp
|
DSView/pv/dialogs/waitingdialog.cpp
|
||||||
DSView/pv/dialogs/dsomeasure.cpp
|
DSView/pv/dialogs/dsomeasure.cpp
|
||||||
DSView/pv/dialogs/calibration.cpp
|
DSView/pv/dialogs/calibration.cpp
|
||||||
@ -350,6 +344,7 @@ set(DSView_SOURCES
|
|||||||
DSView/pv/dialogs/decoderoptionsdlg.cpp
|
DSView/pv/dialogs/decoderoptionsdlg.cpp
|
||||||
DSView/pv/utility/encoding.cpp
|
DSView/pv/utility/encoding.cpp
|
||||||
DSView/pv/utility/path.cpp
|
DSView/pv/utility/path.cpp
|
||||||
|
DSView/pv/deviceagent.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DSView_HEADERS
|
set(DSView_HEADERS
|
||||||
@ -388,7 +383,6 @@ set(DSView_HEADERS
|
|||||||
DSView/pv/widgets/decodermenu.h
|
DSView/pv/widgets/decodermenu.h
|
||||||
DSView/pv/widgets/decodergroupbox.h
|
DSView/pv/widgets/decodergroupbox.h
|
||||||
DSView/pv/prop/string.h
|
DSView/pv/prop/string.h
|
||||||
DSView/pv/device/devinst.h
|
|
||||||
DSView/pv/dialogs/storeprogress.h
|
DSView/pv/dialogs/storeprogress.h
|
||||||
DSView/pv/storesession.h
|
DSView/pv/storesession.h
|
||||||
DSView/pv/view/devmode.h
|
DSView/pv/view/devmode.h
|
||||||
@ -441,6 +435,7 @@ set(DSView_HEADERS
|
|||||||
DSView/pv/dialogs/decoderoptionsdlg.h
|
DSView/pv/dialogs/decoderoptionsdlg.h
|
||||||
DSView/pv/utility/encoding.h
|
DSView/pv/utility/encoding.h
|
||||||
DSView/pv/utility/path.h
|
DSView/pv/utility/path.h
|
||||||
|
DSView/pv/deviceagent.h
|
||||||
)
|
)
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@ -450,7 +445,6 @@ set(libsigrok4DSL_SOURCES
|
|||||||
libsigrok4DSL/version.c
|
libsigrok4DSL/version.c
|
||||||
libsigrok4DSL/strutil.c
|
libsigrok4DSL/strutil.c
|
||||||
libsigrok4DSL/std.c
|
libsigrok4DSL/std.c
|
||||||
libsigrok4DSL/session_file.c
|
|
||||||
libsigrok4DSL/session_driver.c
|
libsigrok4DSL/session_driver.c
|
||||||
libsigrok4DSL/session.c
|
libsigrok4DSL/session.c
|
||||||
libsigrok4DSL/log.c
|
libsigrok4DSL/log.c
|
||||||
@ -475,11 +469,11 @@ set(libsigrok4DSL_SOURCES
|
|||||||
libsigrok4DSL/hardware/DSL/dscope.c
|
libsigrok4DSL/hardware/DSL/dscope.c
|
||||||
libsigrok4DSL/hardware/DSL/command.c
|
libsigrok4DSL/hardware/DSL/command.c
|
||||||
libsigrok4DSL/hardware/DSL/dsl.c
|
libsigrok4DSL/hardware/DSL/dsl.c
|
||||||
|
libsigrok4DSL/lib_main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(libsigrok4DSL_HEADERS
|
set(libsigrok4DSL_HEADERS
|
||||||
libsigrok4DSL/version.h
|
libsigrok4DSL/version.h
|
||||||
libsigrok4DSL/proto.h
|
|
||||||
libsigrok4DSL/libsigrok-internal.h
|
libsigrok4DSL/libsigrok-internal.h
|
||||||
libsigrok4DSL/libsigrok.h
|
libsigrok4DSL/libsigrok.h
|
||||||
libsigrok4DSL/config.h
|
libsigrok4DSL/config.h
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
/* DSView version information */
|
/* DSView version information */
|
||||||
#define DS_VERSION_MAJOR 1
|
#define DS_VERSION_MAJOR 1
|
||||||
#define DS_VERSION_MINOR 2
|
#define DS_VERSION_MINOR 3
|
||||||
#define DS_VERSION_MICRO 1
|
#define DS_VERSION_MICRO 0
|
||||||
#define DS_VERSION_STRING "1.2.1"
|
#define DS_VERSION_STRING "1.3.0-dev"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "pv/config/appconfig.h"
|
#include "pv/config/appconfig.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "pv/appcontrol.h"
|
#include "pv/appcontrol.h"
|
||||||
#include "pv/log.h"
|
#include "pv/log.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -49,14 +49,14 @@ void usage()
|
|||||||
"Help Options:\n"
|
"Help Options:\n"
|
||||||
" -l, --loglevel Set log level, value between 0 to 5\n"
|
" -l, --loglevel Set log level, value between 0 to 5\n"
|
||||||
" -v, -V, --version Show release version\n"
|
" -v, -V, --version Show release version\n"
|
||||||
" -s, --storelog save log to locale file\n"
|
" -s, --storelog Save log to locale file\n"
|
||||||
" -h, -?, --help Show help option\n"
|
" -h, -?, --help Show help option\n"
|
||||||
"\n", DS_BIN_NAME, DS_DESCRIPTION);
|
"\n", DS_BIN_NAME, DS_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
//return main2();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const char *open_file = NULL;
|
const char *open_file = NULL;
|
||||||
int logLevel = -1;
|
int logLevel = -1;
|
||||||
@ -208,7 +208,7 @@ bool bHighScale = true;
|
|||||||
//----------------------run
|
//----------------------run
|
||||||
dsv_info("----------------- version: %s-----------------", DS_VERSION_STRING);
|
dsv_info("----------------- version: %s-----------------", DS_VERSION_STRING);
|
||||||
dsv_info("Qt:%s", QT_VERSION_STR);
|
dsv_info("Qt:%s", QT_VERSION_STR);
|
||||||
|
|
||||||
//init core
|
//init core
|
||||||
if (!control->Init()){
|
if (!control->Init()){
|
||||||
dsv_err("%s", "init error!");
|
dsv_err("%s", "init error!");
|
||||||
@ -222,8 +222,8 @@ bool bHighScale = true;
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
pv::MainFrame w;
|
||||||
control->Start();
|
control->Start();
|
||||||
pv::MainFrame w; //Initialise the main frame
|
|
||||||
w.show();
|
w.show();
|
||||||
w.readSettings();
|
w.readSettings();
|
||||||
w.show_doc(); //to show the dailog for open help document
|
w.show_doc(); //to show the dailog for open help document
|
||||||
|
@ -21,14 +21,12 @@
|
|||||||
|
|
||||||
#include "appcontrol.h"
|
#include "appcontrol.h"
|
||||||
|
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "devicemanager.h"
|
|
||||||
#include "sigsession.h"
|
#include "sigsession.h"
|
||||||
#include "dsvdef.h"
|
#include "dsvdef.h"
|
||||||
#include "config/appconfig.h"
|
#include "config/appconfig.h"
|
||||||
@ -38,11 +36,8 @@
|
|||||||
|
|
||||||
AppControl::AppControl()
|
AppControl::AppControl()
|
||||||
{
|
{
|
||||||
sr_ctx = NULL;
|
_topWindow = NULL;
|
||||||
_topWindow = NULL;
|
_session = new pv::SigSession();
|
||||||
|
|
||||||
_device_manager = new pv::DeviceManager();
|
|
||||||
_session = new pv::SigSession(_device_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControl::AppControl(AppControl &o)
|
AppControl::AppControl(AppControl &o)
|
||||||
@ -51,8 +46,7 @@ AppControl::AppControl(AppControl &o)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppControl::~AppControl()
|
AppControl::~AppControl()
|
||||||
{
|
{
|
||||||
DESTROY_OBJECT(_device_manager);
|
|
||||||
DESTROY_OBJECT(_session);
|
DESTROY_OBJECT(_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,24 +64,12 @@ void AppControl::Destroy(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AppControl::Init()
|
bool AppControl::Init()
|
||||||
{
|
{
|
||||||
pv::encoding::init();
|
_session->init();
|
||||||
|
|
||||||
sr_log_set_context(dsv_log_context());
|
|
||||||
srd_log_set_context(dsv_log_context());
|
|
||||||
|
|
||||||
// Initialise libsigrok
|
|
||||||
if (sr_init(&sr_ctx) != SR_OK)
|
|
||||||
{
|
|
||||||
m_error = "DSView run ERROR: libsigrok init failed.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_session->set_sr_context(sr_ctx);
|
|
||||||
|
|
||||||
// firmware resource directory
|
pv::encoding::init();
|
||||||
QString resdir = GetResourceDir();
|
|
||||||
std::string res_path = pv::path::ToUnicodePath(resdir);
|
srd_log_set_context(dsv_log_context());
|
||||||
sr_set_firmware_resource_dir(res_path.c_str());
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(DEBUG_INFO)
|
#if defined(_WIN32) && defined(DEBUG_INFO)
|
||||||
//able run debug with qtcreator
|
//able run debug with qtcreator
|
||||||
@ -105,7 +87,7 @@ bool AppControl::Init()
|
|||||||
QString dir = GetDecodeScriptDir();
|
QString dir = GetDecodeScriptDir();
|
||||||
strcpy(path, dir.toUtf8().data());
|
strcpy(path, dir.toUtf8().data());
|
||||||
|
|
||||||
dsv_info("decode script path: \"%s\"", dir.toUtf8().data());
|
dsv_info("Decode script files directory:\"%s\"", dir.toUtf8().data());
|
||||||
|
|
||||||
// Initialise libsigrokdecode
|
// Initialise libsigrokdecode
|
||||||
if (srd_init(path) != SRD_OK)
|
if (srd_init(path) != SRD_OK)
|
||||||
@ -126,15 +108,13 @@ bool AppControl::Init()
|
|||||||
|
|
||||||
bool AppControl::Start()
|
bool AppControl::Start()
|
||||||
{
|
{
|
||||||
_session->Open();
|
_session->Open();
|
||||||
_device_manager->initAll(sr_ctx);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppControl::Stop()
|
void AppControl::Stop()
|
||||||
{
|
{
|
||||||
_session->Close();
|
_session->Close();
|
||||||
_device_manager->UnInitAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppControl::UnInit()
|
void AppControl::UnInit()
|
||||||
@ -142,11 +122,7 @@ void AppControl::UnInit()
|
|||||||
// Destroy libsigrokdecode
|
// Destroy libsigrokdecode
|
||||||
srd_exit();
|
srd_exit();
|
||||||
|
|
||||||
if (sr_ctx)
|
_session->uninit();
|
||||||
{
|
|
||||||
sr_exit(sr_ctx);
|
|
||||||
sr_ctx = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *AppControl::GetLastError()
|
const char *AppControl::GetLastError()
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
struct sr_context;
|
struct sr_context;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace pv{
|
namespace pv{
|
||||||
class DeviceManager;
|
|
||||||
class SigSession;
|
class SigSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,11 +54,7 @@ public:
|
|||||||
|
|
||||||
inline pv::SigSession* GetSession(){
|
inline pv::SigSession* GetSession(){
|
||||||
return _session;
|
return _session;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline pv::DeviceManager& GetDeviceManager(){
|
|
||||||
return *_device_manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SetTopWindow(QWidget *w){
|
inline void SetTopWindow(QWidget *w){
|
||||||
_topWindow = w;
|
_topWindow = w;
|
||||||
@ -75,9 +70,7 @@ public:
|
|||||||
std::string _open_file_name;
|
std::string _open_file_name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_error;
|
std::string m_error;
|
||||||
struct sr_context *sr_ctx;
|
|
||||||
pv::DeviceManager *_device_manager;
|
|
||||||
pv::SigSession *_session;
|
pv::SigSession *_session;
|
||||||
QWidget *_topWindow;
|
QWidget *_topWindow;
|
||||||
};
|
};
|
||||||
|
@ -92,6 +92,7 @@ void AnalogSnapshot::clear()
|
|||||||
free_data();
|
free_data();
|
||||||
free_envelop();
|
free_envelop();
|
||||||
init_all();
|
init_all();
|
||||||
|
_have_data = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, GSList *channels)
|
void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t total_sample_count, GSList *channels)
|
||||||
@ -173,6 +174,8 @@ void AnalogSnapshot::append_payload(
|
|||||||
// Generate the first mip-map from the data
|
// Generate the first mip-map from the data
|
||||||
if (analog.num_samples != 0) // guarantee new samples to compute
|
if (analog.num_samples != 0) // guarantee new samples to compute
|
||||||
append_payload_to_envelope_levels();
|
append_payload_to_envelope_levels();
|
||||||
|
|
||||||
|
_have_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalogSnapshot::append_data(void *data, uint64_t samples, uint16_t pitch)
|
void AnalogSnapshot::append_data(void *data, uint64_t samples, uint16_t pitch)
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#ifndef DSVIEW_PV_DATA_ANALOGSNAPSHOT_H
|
#ifndef DSVIEW_PV_DATA_ANALOGSNAPSHOT_H
|
||||||
#define DSVIEW_PV_DATA_ANALOGSNAPSHOT_H
|
#define DSVIEW_PV_DATA_ANALOGSNAPSHOT_H
|
||||||
|
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
|
|
||||||
#include "snapshot.h"
|
#include "snapshot.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -212,8 +212,7 @@ const char* AnnotationResTable::format_to_string(const char *hex_str, int fmt)
|
|||||||
sprintf(g_number_tmp_64, "%c", (char)lv);
|
sprintf(g_number_tmp_64, "%c", (char)lv);
|
||||||
return g_number_tmp_64;
|
return g_number_tmp_64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char * const wr_buf = g_number_tmp_64;
|
|
||||||
g_number_tmp_64[0] = '[';
|
g_number_tmp_64[0] = '[';
|
||||||
strcpy(g_number_tmp_64 + 1, data);
|
strcpy(g_number_tmp_64 + 1, data);
|
||||||
g_number_tmp_64[len+1] = ']';
|
g_number_tmp_64[len+1] = ']';
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "row.h"
|
#include "row.h"
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
|
||||||
#include "decode/annotation.h"
|
#include "decode/annotation.h"
|
||||||
#include "decode/rowdata.h"
|
#include "decode/rowdata.h"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#ifndef DSVIEW_PV_DATA_DECODERSTACK_H
|
#ifndef DSVIEW_PV_DATA_DECODERSTACK_H
|
||||||
#define DSVIEW_PV_DATA_DECODERSTACK_H
|
#define DSVIEW_PV_DATA_DECODERSTACK_H
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -95,6 +95,7 @@ void DsoSnapshot::clear()
|
|||||||
free_data();
|
free_data();
|
||||||
free_envelop();
|
free_envelop();
|
||||||
init_all();
|
init_all();
|
||||||
|
_have_data = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count,
|
void DsoSnapshot::first_payload(const sr_datafeed_dso &dso, uint64_t total_sample_count,
|
||||||
@ -166,6 +167,8 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso)
|
|||||||
// Generate the first mip-map from the data
|
// Generate the first mip-map from the data
|
||||||
if (_envelope_en)
|
if (_envelope_en)
|
||||||
append_payload_to_envelope_levels(dso.samplerate_tog);
|
append_payload_to_envelope_levels(dso.samplerate_tog);
|
||||||
|
|
||||||
|
_have_data = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
#include "snapshot.h"
|
#include "snapshot.h"
|
||||||
|
|
||||||
namespace DsoSnapshotTest {
|
namespace DsoSnapshotTest {
|
||||||
|
@ -99,6 +99,7 @@ void LogicSnapshot::clear()
|
|||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
free_data();
|
free_data();
|
||||||
init_all();
|
init_all();
|
||||||
|
_have_data = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicSnapshot::capture_ended()
|
void LogicSnapshot::capture_ended()
|
||||||
@ -228,6 +229,8 @@ void LogicSnapshot::append_payload(const sr_datafeed_logic &logic)
|
|||||||
append_cross_payload(logic);
|
append_cross_payload(logic);
|
||||||
else if (logic.format == LA_SPLIT_DATA)
|
else if (logic.format == LA_SPLIT_DATA)
|
||||||
append_split_payload(logic);
|
append_split_payload(logic);
|
||||||
|
|
||||||
|
_have_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#ifndef DSVIEW_PV_DATA_LOGICSNAPSHOT_H
|
#ifndef DSVIEW_PV_DATA_LOGICSNAPSHOT_H
|
||||||
#define DSVIEW_PV_DATA_LOGICSNAPSHOT_H
|
#define DSVIEW_PV_DATA_LOGICSNAPSHOT_H
|
||||||
|
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
#include "snapshot.h"
|
#include "snapshot.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -43,6 +43,7 @@ Snapshot::Snapshot(int unit_size, uint64_t total_sample_count, unsigned int chan
|
|||||||
assert(_unit_size > 0);
|
assert(_unit_size > 0);
|
||||||
_unit_bytes = 1;
|
_unit_bytes = 1;
|
||||||
_unit_pitch = 0;
|
_unit_pitch = 0;
|
||||||
|
_have_data = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Snapshot::~Snapshot()
|
Snapshot::~Snapshot()
|
||||||
|
@ -73,10 +73,15 @@ public:
|
|||||||
return _channel_num;
|
return _channel_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool have_data(){
|
||||||
|
return _have_data;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void capture_ended();
|
virtual void capture_ended();
|
||||||
virtual bool has_data(int index) = 0;
|
virtual bool has_data(int index) = 0;
|
||||||
virtual int get_block_num() = 0;
|
virtual int get_block_num() = 0;
|
||||||
virtual uint64_t get_block_size(int block_index) = 0;
|
virtual uint64_t get_block_size(int block_index) = 0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void free_data();
|
virtual void free_data();
|
||||||
@ -105,6 +110,7 @@ protected:
|
|||||||
uint16_t _unit_pitch;
|
uint16_t _unit_pitch;
|
||||||
bool _memory_failed;
|
bool _memory_failed;
|
||||||
bool _last_ended;
|
bool _last_ended;
|
||||||
|
bool _have_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace data
|
} // namespace data
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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 <sstream>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "device.h"
|
|
||||||
|
|
||||||
using std::ostringstream;
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
Device::Device(sr_dev_inst *sdi) :
|
|
||||||
_sdi(sdi)
|
|
||||||
{
|
|
||||||
assert(_sdi);
|
|
||||||
}
|
|
||||||
|
|
||||||
Device::~Device()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_dev_inst* Device::dev_inst()
|
|
||||||
{
|
|
||||||
return _sdi;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Device::use(SigSession *owner)
|
|
||||||
{
|
|
||||||
DevInst::use(owner);
|
|
||||||
|
|
||||||
sr_session_new();
|
|
||||||
sr_dev_open(_sdi);
|
|
||||||
|
|
||||||
_usable = (_sdi->status == SR_ST_ACTIVE);
|
|
||||||
if (sr_session_dev_add(_sdi) != SR_OK)
|
|
||||||
throw QString(tr("Failed to use device."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Device::release()
|
|
||||||
{
|
|
||||||
if (_owner) {
|
|
||||||
DevInst::release();
|
|
||||||
sr_session_destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_dev_close(_sdi);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Device::format_device_title()
|
|
||||||
{
|
|
||||||
ostringstream s;
|
|
||||||
|
|
||||||
if (_sdi->model && _sdi->model[0]) {
|
|
||||||
s << _sdi->model;
|
|
||||||
if (_sdi->version && _sdi->version[0])
|
|
||||||
s << ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_sdi->version && _sdi->version[0])
|
|
||||||
s << _sdi->version;
|
|
||||||
|
|
||||||
return QString::fromStdString(s.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Device::is_trigger_enabled()
|
|
||||||
{
|
|
||||||
for (const GSList *l = _sdi->channels; l; l = l->next) {
|
|
||||||
const sr_channel *const p = (const sr_channel *)l->data;
|
|
||||||
assert(p);
|
|
||||||
if (p->trigger && p->trigger[0] != '\0')
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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_DEVICE_DEVICE_H
|
|
||||||
#define DSVIEW_PV_DEVICE_DEVICE_H
|
|
||||||
|
|
||||||
#include "devinst.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
class Device : public DevInst
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Device(sr_dev_inst *dev_inst);
|
|
||||||
|
|
||||||
~Device();
|
|
||||||
|
|
||||||
sr_dev_inst* dev_inst();
|
|
||||||
|
|
||||||
void use(SigSession *owner);
|
|
||||||
|
|
||||||
void release();
|
|
||||||
|
|
||||||
QString format_device_title();
|
|
||||||
|
|
||||||
bool is_trigger_enabled();
|
|
||||||
|
|
||||||
private:
|
|
||||||
sr_dev_inst *const _sdi;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICE_DEVICE_H
|
|
@ -1,226 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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 <cassert>
|
|
||||||
#include "devinst.h"
|
|
||||||
#include "../sigsession.h"
|
|
||||||
#include "../log.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
DevInst::DevInst() :
|
|
||||||
_owner(NULL),
|
|
||||||
_usable(true)
|
|
||||||
{
|
|
||||||
_id = malloc(1);
|
|
||||||
_is_file = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DevInst::~DevInst()
|
|
||||||
{
|
|
||||||
assert(_id);
|
|
||||||
free(_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* DevInst::get_id()
|
|
||||||
{
|
|
||||||
assert(_id);
|
|
||||||
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::use(SigSession *owner)
|
|
||||||
{
|
|
||||||
assert(owner);
|
|
||||||
_owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::release()
|
|
||||||
{
|
|
||||||
if (_owner) {
|
|
||||||
_owner->release_device(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SigSession* DevInst::owner()
|
|
||||||
{
|
|
||||||
return _owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
GVariant* DevInst::get_config(const sr_channel *ch, const sr_channel_group *group, int key)
|
|
||||||
{
|
|
||||||
GVariant *data = NULL;
|
|
||||||
assert(_owner);
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
if (sr_config_get(sdi->driver, sdi, ch, group, key, &data) != SR_OK)
|
|
||||||
return NULL;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DevInst::set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data)
|
|
||||||
{
|
|
||||||
assert(_owner);
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
if(sr_config_set(sdi, ch, group, key, data) == SR_OK) {
|
|
||||||
config_changed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GVariant* DevInst::list_config(const sr_channel_group *group, int key)
|
|
||||||
{
|
|
||||||
GVariant *data = NULL;
|
|
||||||
assert(_owner);
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
if (sr_config_list(sdi->driver, sdi, group, key, &data) != SR_OK)
|
|
||||||
return NULL;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::enable_probe(const sr_channel *probe, bool enable)
|
|
||||||
{
|
|
||||||
assert(_owner);
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
for (const GSList *p = sdi->channels; p; p = p->next)
|
|
||||||
if (probe == p->data) {
|
|
||||||
const_cast<sr_channel*>(probe)->enabled = enable;
|
|
||||||
config_changed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Probe was not found in the device
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t DevInst::get_sample_limit()
|
|
||||||
{
|
|
||||||
uint64_t sample_limit;
|
|
||||||
GVariant* gvar = get_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES);
|
|
||||||
if (gvar != NULL) {
|
|
||||||
sample_limit = g_variant_get_uint64(gvar);
|
|
||||||
g_variant_unref(gvar);
|
|
||||||
} else {
|
|
||||||
sample_limit = 0U;
|
|
||||||
}
|
|
||||||
return sample_limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t DevInst::get_sample_rate()
|
|
||||||
{
|
|
||||||
uint64_t sample_rate;
|
|
||||||
GVariant* gvar = get_config(NULL, NULL, SR_CONF_SAMPLERATE);
|
|
||||||
if (gvar != NULL) {
|
|
||||||
sample_rate = g_variant_get_uint64(gvar);
|
|
||||||
g_variant_unref(gvar);
|
|
||||||
} else {
|
|
||||||
sample_rate = 0U;
|
|
||||||
}
|
|
||||||
return sample_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t DevInst::get_time_base()
|
|
||||||
{
|
|
||||||
uint64_t time_base;
|
|
||||||
GVariant* gvar = get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
|
||||||
if (gvar != NULL) {
|
|
||||||
time_base = g_variant_get_uint64(gvar);
|
|
||||||
g_variant_unref(gvar);
|
|
||||||
} else {
|
|
||||||
time_base = 0U;
|
|
||||||
}
|
|
||||||
return time_base;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double DevInst::get_sample_time()
|
|
||||||
{
|
|
||||||
uint64_t sample_rate = get_sample_rate();
|
|
||||||
uint64_t sample_limit = get_sample_limit();
|
|
||||||
double sample_time;
|
|
||||||
|
|
||||||
if (sample_rate == 0)
|
|
||||||
sample_time = 0;
|
|
||||||
else
|
|
||||||
sample_time = sample_limit * 1.0 / sample_rate;
|
|
||||||
|
|
||||||
return sample_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
const GSList* DevInst::get_dev_mode_list()
|
|
||||||
{
|
|
||||||
assert(_owner);
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
return sr_dev_mode_list(sdi);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DevInst::name()
|
|
||||||
{
|
|
||||||
sr_dev_inst *const sdi = dev_inst();
|
|
||||||
assert(sdi);
|
|
||||||
return QString::fromLocal8Bit(sdi->driver->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DevInst::is_trigger_enabled()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::start()
|
|
||||||
{
|
|
||||||
if (sr_session_start() != SR_OK)
|
|
||||||
throw tr("Failed to start session.");
|
|
||||||
//assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::run()
|
|
||||||
{
|
|
||||||
dsv_info("%s", "session run loop start");
|
|
||||||
int ret = sr_session_run();
|
|
||||||
if (ret != SR_OK){
|
|
||||||
dsv_err("%s", "start session error!");
|
|
||||||
}
|
|
||||||
dsv_info("%s", "session run loop end");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::stop()
|
|
||||||
{
|
|
||||||
sr_session_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DevInst::is_usable()
|
|
||||||
{
|
|
||||||
return _usable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevInst::destroy(){
|
|
||||||
release();
|
|
||||||
//delete this; //do not to destroy
|
|
||||||
}
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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_DEVICE_DEVINST_H
|
|
||||||
#define DSVIEW_PV_DEVICE_DEVINST_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "libsigrok.h"
|
|
||||||
|
|
||||||
struct sr_dev_inst;
|
|
||||||
struct sr_channel;
|
|
||||||
struct sr_channel_group;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
|
|
||||||
class SigSession;
|
|
||||||
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
class DevInst : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DevInst();
|
|
||||||
|
|
||||||
virtual ~DevInst();
|
|
||||||
|
|
||||||
public:
|
|
||||||
SigSession* owner();
|
|
||||||
|
|
||||||
GVariant* get_config(const sr_channel *ch, const sr_channel_group *group, int key);
|
|
||||||
|
|
||||||
bool set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data);
|
|
||||||
|
|
||||||
GVariant* list_config(const sr_channel_group *group, int key);
|
|
||||||
|
|
||||||
void enable_probe(const sr_channel *probe, bool enable = true);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the sample limit from the driver.
|
|
||||||
*
|
|
||||||
* @return The returned sample limit from the driver, or 0 if the
|
|
||||||
* sample limit could not be read.
|
|
||||||
*/
|
|
||||||
uint64_t get_sample_limit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the sample rate from the driver.
|
|
||||||
*
|
|
||||||
* @return The returned sample rate from the driver, or 0 if the
|
|
||||||
* sample rate could not be read.
|
|
||||||
*/
|
|
||||||
uint64_t get_sample_rate();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the sample time from the driver.
|
|
||||||
*
|
|
||||||
* @return The returned sample time from the driver, or 0 if the
|
|
||||||
* sample time could not be read.
|
|
||||||
*/
|
|
||||||
double get_sample_time();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the time base from the driver.
|
|
||||||
*
|
|
||||||
* @return The returned time base from the driver, or 0 if the
|
|
||||||
* time base could not be read.
|
|
||||||
*/
|
|
||||||
uint64_t get_time_base();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the device mode list from the driver.
|
|
||||||
*
|
|
||||||
* @return The returned device mode list from the driver, or NULL if the
|
|
||||||
* mode list could not be read.
|
|
||||||
*/
|
|
||||||
const GSList *get_dev_mode_list();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the device name from the driver
|
|
||||||
*
|
|
||||||
* @return device name
|
|
||||||
*/
|
|
||||||
QString name();
|
|
||||||
|
|
||||||
bool is_usable();
|
|
||||||
void destroy();
|
|
||||||
|
|
||||||
inline bool is_file(){
|
|
||||||
return _is_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void start();
|
|
||||||
|
|
||||||
virtual void run();
|
|
||||||
|
|
||||||
virtual void stop();
|
|
||||||
|
|
||||||
virtual void* get_id();
|
|
||||||
|
|
||||||
virtual sr_dev_inst* dev_inst() = 0;
|
|
||||||
|
|
||||||
virtual void use(SigSession *owner);
|
|
||||||
|
|
||||||
virtual void release();
|
|
||||||
|
|
||||||
virtual bool is_trigger_enabled();
|
|
||||||
|
|
||||||
virtual QString format_device_title() = 0;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void device_updated();
|
|
||||||
void config_changed();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SigSession *_owner;
|
|
||||||
void *_id;
|
|
||||||
bool _usable;
|
|
||||||
bool _is_file;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICE_DEVINST_H
|
|
@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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 "file.h"
|
|
||||||
#include "inputfile.h"
|
|
||||||
#include "sessionfile.h"
|
|
||||||
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <assert.h>
|
|
||||||
#include "../utility/path.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "../ZipMaker.h"
|
|
||||||
#include "../log.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
File::File(QString path)
|
|
||||||
:_path(path)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
File::~File(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString File::format_device_title()
|
|
||||||
{
|
|
||||||
QFileInfo fi(_path);
|
|
||||||
return fi.fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
File* File::create(QString name)
|
|
||||||
{
|
|
||||||
auto f_name = path::ConvertPath(name);
|
|
||||||
|
|
||||||
if (sr_session_load(f_name.c_str()) == SR_OK) {
|
|
||||||
GSList *devlist = NULL;
|
|
||||||
sr_session_dev_list(&devlist);
|
|
||||||
sr_session_destroy();
|
|
||||||
|
|
||||||
if (devlist) {
|
|
||||||
sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
|
|
||||||
g_slist_free(devlist);
|
|
||||||
if (sdi) {
|
|
||||||
sr_dev_close(sdi);
|
|
||||||
sr_dev_clear(sdi->driver);
|
|
||||||
return new SessionFile(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new InputFile(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonArray File::get_decoders()
|
|
||||||
{
|
|
||||||
QJsonArray dec_array;
|
|
||||||
QJsonParseError error;
|
|
||||||
|
|
||||||
/* read "decoders" */
|
|
||||||
auto f_name = path::ConvertPath(_path);
|
|
||||||
ZipReader rd(f_name.c_str());
|
|
||||||
auto *data = rd.GetInnterFileData("decoders");
|
|
||||||
|
|
||||||
if (data != NULL){
|
|
||||||
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
|
|
||||||
QString jsonStr(raw_bytes.data());
|
|
||||||
QByteArray qbs = jsonStr.toUtf8();
|
|
||||||
QJsonDocument sessionDoc = QJsonDocument::fromJson(qbs, &error);
|
|
||||||
|
|
||||||
if (error.error != QJsonParseError::NoError){
|
|
||||||
QString estr = error.errorString();
|
|
||||||
dsv_err("File::get_decoders(), parse json error:\"%s\"!", estr.toUtf8().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
dec_array = sessionDoc.array();
|
|
||||||
rd.ReleaseInnerFileData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dec_array;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonDocument File::get_session()
|
|
||||||
{
|
|
||||||
QJsonDocument sessionDoc;
|
|
||||||
QJsonParseError error;
|
|
||||||
|
|
||||||
auto f_name = path::ConvertPath(_path);
|
|
||||||
ZipReader rd(f_name.c_str());
|
|
||||||
auto *data = rd.GetInnterFileData("session");
|
|
||||||
|
|
||||||
if (data != NULL){
|
|
||||||
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
|
|
||||||
QString jsonStr(raw_bytes.data());
|
|
||||||
QByteArray qbs = jsonStr.toUtf8();
|
|
||||||
sessionDoc = QJsonDocument::fromJson(qbs, &error);
|
|
||||||
|
|
||||||
if (error.error != QJsonParseError::NoError){
|
|
||||||
QString estr = error.errorString();
|
|
||||||
dsv_err("File::get_session(), parse json error:\"%s\"!", estr.toUtf8().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
rd.ReleaseInnerFileData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sessionDoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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_DEVICE_FILE_H
|
|
||||||
#define DSVIEW_PV_DEVICE_FILE_H
|
|
||||||
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QFile>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "devinst.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
class File : public DevInst
|
|
||||||
{
|
|
||||||
|
|
||||||
protected:
|
|
||||||
File(QString path);
|
|
||||||
|
|
||||||
public:
|
|
||||||
~File();
|
|
||||||
|
|
||||||
static File* create(QString name);
|
|
||||||
QJsonArray get_decoders();
|
|
||||||
QJsonDocument get_session();
|
|
||||||
|
|
||||||
public:
|
|
||||||
QString format_device_title();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const QString _path;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICE_FILE_H
|
|
@ -1,139 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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 <cassert>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "inputfile.h"
|
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
InputFile::InputFile(QString path) :
|
|
||||||
File(path),
|
|
||||||
_input(NULL)
|
|
||||||
{
|
|
||||||
_is_file = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_dev_inst* InputFile::dev_inst()
|
|
||||||
{
|
|
||||||
assert(_input);
|
|
||||||
return _input->sdi;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputFile::use(SigSession *owner)
|
|
||||||
{
|
|
||||||
(void)owner;
|
|
||||||
assert(!_input);
|
|
||||||
|
|
||||||
// only *.dsl file is valid
|
|
||||||
// don't allow other types of file input
|
|
||||||
throw tr("Not a valid DSView data file.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputFile::release()
|
|
||||||
{
|
|
||||||
if (!_owner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
assert(_input);
|
|
||||||
File::release();
|
|
||||||
sr_dev_close(_input->sdi);
|
|
||||||
sr_session_destroy();
|
|
||||||
_input = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_input_format* InputFile::determine_input_file_format(const QString filename)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* If there are no input formats, return NULL right away. */
|
|
||||||
sr_input_format *const *const inputs = sr_input_list();
|
|
||||||
if (!inputs) {
|
|
||||||
g_critical("No supported input formats available.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, try to find an input module that can handle this file. */
|
|
||||||
for (i = 0; inputs[i]; i++) {
|
|
||||||
if (inputs[i]->format_match(filename.toUtf8().data()))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return NULL if no input module wanted to touch this. */
|
|
||||||
if (!inputs[i]) {
|
|
||||||
g_critical("Error: no matching input module found.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputs[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_input* InputFile::load_input_file_format(const QString filename,
|
|
||||||
sr_input_format *format)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
sr_input *in;
|
|
||||||
|
|
||||||
if (!format && !(format =
|
|
||||||
determine_input_file_format(filename))) {
|
|
||||||
/* The exact cause was already logged. */
|
|
||||||
throw tr("Failed to load file");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(filename.toUtf8().data(), &st) == -1)
|
|
||||||
throw tr("Failed to load file");
|
|
||||||
|
|
||||||
/* Initialize the input module. */
|
|
||||||
if (!(in = new sr_input)) {
|
|
||||||
throw tr("Failed to allocate input module.");
|
|
||||||
}
|
|
||||||
|
|
||||||
in->format = format;
|
|
||||||
in->param = NULL;
|
|
||||||
if (in->format->init &&
|
|
||||||
in->format->init(in, filename.toUtf8().data()) != SR_OK) {
|
|
||||||
throw tr("Failed to load file");
|
|
||||||
}
|
|
||||||
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputFile::start()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputFile::run()
|
|
||||||
{
|
|
||||||
assert(_input);
|
|
||||||
assert(_input->format);
|
|
||||||
assert(_input->format->loadfile);
|
|
||||||
_input->format->loadfile(_input, _path.toUtf8().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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_DEVICE_INPUTFILE_H
|
|
||||||
#define DSVIEW_PV_DEVICE_INPUTFILE_H
|
|
||||||
|
|
||||||
#include "file.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
struct sr_input;
|
|
||||||
struct sr_input_format;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
class InputFile : public File
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InputFile(QString path);
|
|
||||||
|
|
||||||
sr_dev_inst* dev_inst();
|
|
||||||
|
|
||||||
virtual void use(SigSession *owner);
|
|
||||||
|
|
||||||
virtual void release();
|
|
||||||
|
|
||||||
virtual void start();
|
|
||||||
|
|
||||||
virtual void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Attempts to autodetect the format. Failing that
|
|
||||||
* @param filename The filename of the input file.
|
|
||||||
* @return A pointer to the 'struct sr_input_format' that should be used,
|
|
||||||
* or NULL if no input format was selected or auto-detected.
|
|
||||||
*/
|
|
||||||
static sr_input_format* determine_input_file_format(
|
|
||||||
const QString filename);
|
|
||||||
|
|
||||||
static sr_input* load_input_file_format(const QString filename,
|
|
||||||
sr_input_format *format);
|
|
||||||
private:
|
|
||||||
sr_input *_input;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICE_INPUTFILE_H
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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 "sessionfile.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include "../utility/path.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
SessionFile::SessionFile(QString path) :
|
|
||||||
File(path)
|
|
||||||
{
|
|
||||||
_sdi = NULL;
|
|
||||||
_is_file = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sr_dev_inst* SessionFile::dev_inst()
|
|
||||||
{
|
|
||||||
return _sdi;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionFile::use(SigSession *owner)
|
|
||||||
{
|
|
||||||
if (_sdi){
|
|
||||||
release_source();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto f_name = path::ConvertPath(_path);
|
|
||||||
|
|
||||||
if (sr_session_load(f_name.c_str()) != SR_OK)
|
|
||||||
throw tr("Failed to open file.\n");
|
|
||||||
|
|
||||||
GSList *devlist = NULL;
|
|
||||||
sr_session_dev_list(&devlist);
|
|
||||||
|
|
||||||
if (!devlist || !devlist->data) {
|
|
||||||
if (devlist)
|
|
||||||
g_slist_free(devlist);
|
|
||||||
throw tr("Failed to start session.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_sdi = (sr_dev_inst*)devlist->data;
|
|
||||||
g_slist_free(devlist);
|
|
||||||
|
|
||||||
File::use(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionFile::release()
|
|
||||||
{
|
|
||||||
release_source();
|
|
||||||
File::release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionFile::release_source()
|
|
||||||
{
|
|
||||||
if (_sdi != NULL)
|
|
||||||
{
|
|
||||||
sr_dev_close(_sdi);
|
|
||||||
sr_dev_clear(_sdi->driver);
|
|
||||||
sr_session_destroy();
|
|
||||||
_sdi = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
||||||
*
|
|
||||||
* 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_DEVICE_SESSIONFILE_H
|
|
||||||
#define DSVIEW_PV_DEVICE_SESSIONFILE_H
|
|
||||||
|
|
||||||
#include "file.h"
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
namespace device {
|
|
||||||
|
|
||||||
class SessionFile : public File
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SessionFile(QString path);
|
|
||||||
sr_dev_inst* dev_inst();
|
|
||||||
virtual void use(SigSession *owner);
|
|
||||||
virtual void release();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void release_source();
|
|
||||||
|
|
||||||
private:
|
|
||||||
sr_dev_inst *_sdi;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // device
|
|
||||||
} // pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICE_SESSIONFILE_H
|
|
352
DSView/pv/deviceagent.cpp
Normal file
352
DSView/pv/deviceagent.cpp
Normal file
@ -0,0 +1,352 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the DSView project.
|
||||||
|
* DSView is based on PulseView.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 DreamSourceLab <support@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 "deviceagent.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
DeviceAgent::DeviceAgent()
|
||||||
|
{
|
||||||
|
_dev_handle = NULL_HANDLE;
|
||||||
|
_di = NULL;
|
||||||
|
_dev_type = 0;
|
||||||
|
_callback = NULL;
|
||||||
|
_is_new_device = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceAgent::update()
|
||||||
|
{
|
||||||
|
_dev_handle = NULL_HANDLE;
|
||||||
|
_dev_name = "";
|
||||||
|
_path = "";
|
||||||
|
_di = NULL;
|
||||||
|
_dev_type = 0;
|
||||||
|
|
||||||
|
struct ds_device_full_info info;
|
||||||
|
|
||||||
|
if (ds_get_actived_device_info(&info) == SR_OK)
|
||||||
|
{
|
||||||
|
_dev_handle = info.handle;
|
||||||
|
_dev_type = info.dev_type;
|
||||||
|
_di = info.di;
|
||||||
|
_dev_name = QString::fromLocal8Bit(info.name);
|
||||||
|
_driver_name = QString::fromLocal8Bit(info.driver_name);
|
||||||
|
|
||||||
|
if (info.path[0] != '\0'){
|
||||||
|
_path = QString::fromLocal8Bit(info.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_in_history(_dev_handle) == false){
|
||||||
|
_is_new_device = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
_is_new_device = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sr_dev_inst* DeviceAgent::inst()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
return _di;
|
||||||
|
}
|
||||||
|
|
||||||
|
GVariant* DeviceAgent::get_config(const sr_channel *ch, const sr_channel_group *group, int key)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
GVariant *data = NULL;
|
||||||
|
if (ds_get_actived_device_config(ch, group, key, &data) != SR_OK)
|
||||||
|
{
|
||||||
|
if (is_hardware())
|
||||||
|
dsv_warn("%s%d", "WARNING: Failed to get value of config id:", key);
|
||||||
|
else
|
||||||
|
dsv_detail("%s%d", "WARNING: Failed to get value of config id:", key);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_set_actived_device_config(ch, group, key, data) != SR_OK)
|
||||||
|
{
|
||||||
|
if (is_hardware())
|
||||||
|
dsv_warn("%s%d", "WARNING: Failed to set value of config id:", key);
|
||||||
|
else
|
||||||
|
dsv_detail("%s%d", "WARNING: Failed to set value of config id:", key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_changed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GVariant* DeviceAgent::get_config_list(const sr_channel_group *group, int key)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
GVariant *data = NULL;
|
||||||
|
|
||||||
|
if (ds_get_actived_device_config_list(group, key, &data) != SR_OK){
|
||||||
|
dsv_warn("%s%d", "WARNING: Failed to get config list, key:", key);
|
||||||
|
if (data != NULL){
|
||||||
|
dsv_warn("%s%d", "WARNING: Failed to get config list, but data is not null. key:", key);
|
||||||
|
}
|
||||||
|
data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::enable_probe(const sr_channel *probe, bool enable)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_enable_device_channel(probe, enable) == SR_OK){
|
||||||
|
config_changed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::enable_probe(int probe_index, bool enable)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_enable_device_channel_index(probe_index, enable) == SR_OK){
|
||||||
|
config_changed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::set_channel_name(int ch_index, const char *name)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_set_device_channel_name(ch_index, name) == SR_OK){
|
||||||
|
config_changed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t DeviceAgent::get_sample_limit()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
uint64_t v;
|
||||||
|
GVariant* gvar = NULL;
|
||||||
|
|
||||||
|
ds_get_actived_device_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES, &gvar);
|
||||||
|
|
||||||
|
if (gvar != NULL) {
|
||||||
|
v = g_variant_get_uint64(gvar);
|
||||||
|
g_variant_unref(gvar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v = 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t DeviceAgent::get_sample_rate()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
uint64_t v;
|
||||||
|
GVariant* gvar = NULL;
|
||||||
|
|
||||||
|
ds_get_actived_device_config(NULL, NULL, SR_CONF_SAMPLERATE, &gvar);
|
||||||
|
|
||||||
|
if (gvar != NULL) {
|
||||||
|
v = g_variant_get_uint64(gvar);
|
||||||
|
g_variant_unref(gvar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v = 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t DeviceAgent::get_time_base()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
uint64_t v;
|
||||||
|
GVariant* gvar = NULL;
|
||||||
|
|
||||||
|
ds_get_actived_device_config(NULL, NULL, SR_CONF_TIMEBASE, &gvar);
|
||||||
|
|
||||||
|
if (gvar != NULL) {
|
||||||
|
v = g_variant_get_uint64(gvar);
|
||||||
|
g_variant_unref(gvar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v = 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
double DeviceAgent::get_sample_time()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
uint64_t sample_rate = get_sample_rate();
|
||||||
|
uint64_t sample_limit = get_sample_limit();
|
||||||
|
double sample_time;
|
||||||
|
|
||||||
|
if (sample_rate == 0)
|
||||||
|
sample_time = 0;
|
||||||
|
else
|
||||||
|
sample_time = sample_limit * 1.0 / sample_rate;
|
||||||
|
|
||||||
|
return sample_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GSList* DeviceAgent::get_device_mode_list()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
return ds_get_actived_device_mode_list();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::is_trigger_enabled()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
if (ds_trigger_is_enabled() > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::start()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_start_collect() == SR_OK){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::stop()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_stop_collect() == SR_OK){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceAgent::release()
|
||||||
|
{
|
||||||
|
ds_release_actived_device();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::have_enabled_channel()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
return ds_channel_is_enabled() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::get_status(struct sr_status &status, gboolean prg)
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
|
||||||
|
if (ds_get_actived_device_status(&status, prg) == SR_OK){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceAgent::config_changed()
|
||||||
|
{
|
||||||
|
if (_callback != NULL){
|
||||||
|
_callback->DeviceConfigChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------device config-----------/
|
||||||
|
|
||||||
|
int DeviceAgent::get_work_mode()
|
||||||
|
{
|
||||||
|
return ds_get_actived_device_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct sr_config_info *DeviceAgent::get_config_info(int key)
|
||||||
|
{
|
||||||
|
return ds_get_actived_device_config_info(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct sr_config_info *DeviceAgent::get_config_info_by_name(const char *optname)
|
||||||
|
{
|
||||||
|
return ds_get_actived_device_config_info_by_name(optname);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::get_device_status(struct sr_status &status, gboolean prg)
|
||||||
|
{
|
||||||
|
if (ds_get_actived_device_status(&status, prg) == SR_OK)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sr_config *DeviceAgent::new_config(int key, GVariant *data)
|
||||||
|
{
|
||||||
|
return ds_new_config(key, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceAgent::free_config(struct sr_config *src)
|
||||||
|
{
|
||||||
|
ds_free_config(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::is_collecting()
|
||||||
|
{
|
||||||
|
return ds_is_collecting() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *DeviceAgent::get_channels()
|
||||||
|
{
|
||||||
|
assert(_dev_handle);
|
||||||
|
return ds_get_actived_device_channels();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceAgent::is_in_history(ds_device_handle dev_handle)
|
||||||
|
{
|
||||||
|
for(ds_device_handle h : _history_handles){
|
||||||
|
if (h == dev_handle){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_history_handles.push_back(dev_handle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------device config end -----------/
|
||||||
|
|
198
DSView/pv/deviceagent.h
Normal file
198
DSView/pv/deviceagent.h
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the DSView project.
|
||||||
|
* DSView is based on PulseView.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 DreamSourceLab <support@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 DEVICE_AGENT_H
|
||||||
|
#define DEVICE_AGENT_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <libsigrok.h>
|
||||||
|
#include <QString>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class IDeviceAgentCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void DeviceConfigChanged()=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DeviceAgent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceAgent();
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
|
inline bool have_instance(){
|
||||||
|
return _dev_handle != NULL_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString name(){
|
||||||
|
return _dev_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString path(){
|
||||||
|
return _path;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString driver_name(){
|
||||||
|
return _driver_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ds_device_handle handle(){
|
||||||
|
return _dev_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sr_dev_inst* inst();
|
||||||
|
|
||||||
|
inline bool is_file(){
|
||||||
|
return _dev_type == DEV_TYPE_FILELOG;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_demo(){
|
||||||
|
return _dev_type == DEV_TYPE_DEMO;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_hardware(){
|
||||||
|
return _dev_type == DEV_TYPE_USB;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_callback(IDeviceAgentCallback *callback){
|
||||||
|
_callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
GVariant* get_config(const sr_channel *ch, const sr_channel_group *group, int key);
|
||||||
|
|
||||||
|
bool set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data);
|
||||||
|
|
||||||
|
GVariant* get_config_list(const sr_channel_group *group, int key);
|
||||||
|
|
||||||
|
bool enable_probe(const sr_channel *probe, bool enable);
|
||||||
|
|
||||||
|
bool enable_probe(int probe_index, bool enable);
|
||||||
|
|
||||||
|
bool set_channel_name(int ch_index, const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the sample limit from the driver.
|
||||||
|
*
|
||||||
|
* @return The returned sample limit from the driver, or 0 if the
|
||||||
|
* sample limit could not be read.
|
||||||
|
*/
|
||||||
|
uint64_t get_sample_limit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the sample rate from the driver.
|
||||||
|
*
|
||||||
|
* @return The returned sample rate from the driver, or 0 if the
|
||||||
|
* sample rate could not be read.
|
||||||
|
*/
|
||||||
|
uint64_t get_sample_rate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the time base from the driver.
|
||||||
|
*
|
||||||
|
* @return The returned time base from the driver, or 0 if the
|
||||||
|
* time base could not be read.
|
||||||
|
*/
|
||||||
|
uint64_t get_time_base();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the sample time from the driver.
|
||||||
|
*
|
||||||
|
* @return The returned sample time from the driver, or 0 if the
|
||||||
|
* sample time could not be read.
|
||||||
|
*/
|
||||||
|
double get_sample_time();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the device mode list from the driver.
|
||||||
|
*
|
||||||
|
* @return The returned device mode list from the driver, or NULL if the
|
||||||
|
* mode list could not be read.
|
||||||
|
*/
|
||||||
|
const GSList *get_device_mode_list();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the trigger exists
|
||||||
|
*/
|
||||||
|
bool is_trigger_enabled();
|
||||||
|
|
||||||
|
bool have_enabled_channel();
|
||||||
|
|
||||||
|
bool get_status(struct sr_status &status, gboolean prg);
|
||||||
|
|
||||||
|
GSList* get_channels();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start collect data.
|
||||||
|
*/
|
||||||
|
bool start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop collect
|
||||||
|
*/
|
||||||
|
bool stop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop and close.
|
||||||
|
*/
|
||||||
|
void release();
|
||||||
|
|
||||||
|
bool is_collecting();
|
||||||
|
|
||||||
|
inline bool is_new_device(){
|
||||||
|
return _is_new_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void config_changed();
|
||||||
|
bool is_in_history(ds_device_handle dev_handle);
|
||||||
|
|
||||||
|
//---------------device config-----------/
|
||||||
|
public:
|
||||||
|
int get_work_mode();
|
||||||
|
|
||||||
|
const struct sr_config_info* get_config_info(int key);
|
||||||
|
|
||||||
|
const struct sr_config_info* get_config_info_by_name(const char *optname);
|
||||||
|
|
||||||
|
bool get_device_status(struct sr_status &status, gboolean prg);
|
||||||
|
|
||||||
|
struct sr_config* new_config(int key, GVariant *data);
|
||||||
|
|
||||||
|
void free_config(struct sr_config *src);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
ds_device_handle _dev_handle;
|
||||||
|
int _dev_type;
|
||||||
|
QString _dev_name;
|
||||||
|
QString _driver_name;
|
||||||
|
QString _path;
|
||||||
|
bool _is_new_device;
|
||||||
|
struct sr_dev_inst *_di;
|
||||||
|
std::vector<ds_device_handle> _history_handles;
|
||||||
|
IDeviceAgentCallback *_callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <support@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 "devicemanager.h"
|
|
||||||
#include "device/devinst.h"
|
|
||||||
#include "device/device.h"
|
|
||||||
#include "sigsession.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QDir>
|
|
||||||
#include "config/appconfig.h"
|
|
||||||
|
|
||||||
using std::list;
|
|
||||||
using std::map;
|
|
||||||
using std::ostringstream;
|
|
||||||
using std::runtime_error;
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
|
|
||||||
DeviceManager::DeviceManager()
|
|
||||||
{
|
|
||||||
_sr_ctx = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceManager::DeviceManager(DeviceManager &o)
|
|
||||||
{
|
|
||||||
(void)o;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceManager::~DeviceManager()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::initAll(struct sr_context *sr_ctx)
|
|
||||||
{
|
|
||||||
_sr_ctx = sr_ctx;
|
|
||||||
init_drivers();
|
|
||||||
scan_all_drivers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::UnInitAll()
|
|
||||||
{
|
|
||||||
release_devices();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::add_device(DevInst *device)
|
|
||||||
{
|
|
||||||
assert(device);
|
|
||||||
|
|
||||||
auto it = std::find(_devices.begin(), _devices.end(), device);
|
|
||||||
if (it ==_devices.end()){
|
|
||||||
_devices.push_front(device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::del_device(DevInst *device)
|
|
||||||
{
|
|
||||||
assert(device);
|
|
||||||
|
|
||||||
auto it = std::find(_devices.begin(), _devices.end(), device);
|
|
||||||
if (it !=_devices.end()){
|
|
||||||
_devices.erase(it); //remove from list
|
|
||||||
device->destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::driver_scan(
|
|
||||||
std::list<DevInst*> &driver_devices,
|
|
||||||
struct sr_dev_driver *const driver,
|
|
||||||
GSList *const drvopts)
|
|
||||||
{
|
|
||||||
assert(driver);
|
|
||||||
|
|
||||||
// Remove any device instances from this driver from the device
|
|
||||||
// list. They will not be valid after the scan.
|
|
||||||
auto i = _devices.begin();
|
|
||||||
while (i != _devices.end()) {
|
|
||||||
if ((*i)->dev_inst() && (*i)->dev_inst()->driver == driver) {
|
|
||||||
(*i)->release();
|
|
||||||
i = _devices.erase(i);
|
|
||||||
} else {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear all the old device instances from this driver
|
|
||||||
sr_dev_clear(driver);
|
|
||||||
//release_driver(driver);
|
|
||||||
|
|
||||||
// Check If DSL hardware driver
|
|
||||||
if (strncmp(driver->name, "virtual", 7)) {
|
|
||||||
QDir dir(GetResourceDir());
|
|
||||||
if (!dir.exists())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do the scan
|
|
||||||
GSList *const devices = sr_driver_scan(driver, drvopts);
|
|
||||||
|
|
||||||
for (GSList *l = devices; l; l = l->next){
|
|
||||||
Device *dev = new device::Device((sr_dev_inst*)l->data); //create new device
|
|
||||||
driver_devices.push_front(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(devices);
|
|
||||||
|
|
||||||
// append the scanned devices to the main list
|
|
||||||
_devices.insert(_devices.end(), driver_devices.begin(), driver_devices.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::init_drivers()
|
|
||||||
{
|
|
||||||
// Initialise all libsigrok drivers
|
|
||||||
sr_dev_driver **const drivers = sr_driver_list();
|
|
||||||
for (sr_dev_driver **driver = drivers; *driver; driver++) {
|
|
||||||
if (sr_driver_init(_sr_ctx, *driver) != SR_OK) {
|
|
||||||
throw runtime_error(
|
|
||||||
string("Failed to initialize driver ") +
|
|
||||||
string((*driver)->name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::release_devices()
|
|
||||||
{
|
|
||||||
// Release all the used devices
|
|
||||||
for (DevInst *dev : _devices) {
|
|
||||||
dev->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear all the drivers
|
|
||||||
sr_dev_driver **const drivers = sr_driver_list();
|
|
||||||
for (sr_dev_driver **driver = drivers; *driver; driver++)
|
|
||||||
sr_dev_clear(*driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::scan_all_drivers()
|
|
||||||
{
|
|
||||||
// Scan all drivers for all devices.
|
|
||||||
struct sr_dev_driver **const drivers = sr_driver_list();
|
|
||||||
for (struct sr_dev_driver **driver = drivers; *driver; driver++){
|
|
||||||
std::list<DevInst*> driver_devices;
|
|
||||||
driver_scan(driver_devices, *driver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceManager::release_driver(struct sr_dev_driver *const driver)
|
|
||||||
{
|
|
||||||
for (DevInst *dev : _devices) {
|
|
||||||
if(dev->dev_inst()->driver == driver)
|
|
||||||
dev->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear all the old device instances from this driver
|
|
||||||
sr_dev_clear(driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeviceManager::compare_devices(DevInst *a, DevInst *b)
|
|
||||||
{
|
|
||||||
assert(a);
|
|
||||||
assert(b);
|
|
||||||
return a->format_device_title().compare(b->format_device_title()) <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace pv
|
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <support@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_DEVICEMANAGER_H
|
|
||||||
#define DSVIEW_PV_DEVICEMANAGER_H
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
struct sr_context;
|
|
||||||
struct sr_dev_driver;
|
|
||||||
struct sr_dev_inst;
|
|
||||||
|
|
||||||
namespace pv {
|
|
||||||
|
|
||||||
class SigSession;
|
|
||||||
|
|
||||||
namespace device {
|
|
||||||
class DevInst;
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace pv::device;
|
|
||||||
|
|
||||||
class DeviceManager
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
DeviceManager(DeviceManager &o);
|
|
||||||
|
|
||||||
public:
|
|
||||||
DeviceManager();
|
|
||||||
|
|
||||||
~DeviceManager();
|
|
||||||
|
|
||||||
inline const std::list<DevInst*>& devices(){
|
|
||||||
return _devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_device(DevInst *device);
|
|
||||||
void del_device(DevInst *device);
|
|
||||||
|
|
||||||
void driver_scan(
|
|
||||||
std::list<DevInst*> &driver_devices,
|
|
||||||
struct sr_dev_driver *const driver=NULL,
|
|
||||||
GSList *const drvopts=NULL);
|
|
||||||
|
|
||||||
void initAll(struct sr_context *sr_ctx);
|
|
||||||
|
|
||||||
void UnInitAll();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void init_drivers();
|
|
||||||
|
|
||||||
void release_devices();
|
|
||||||
|
|
||||||
void scan_all_drivers();
|
|
||||||
|
|
||||||
void release_driver(struct sr_dev_driver *const driver);
|
|
||||||
|
|
||||||
static bool compare_devices(DevInst *a, DevInst *b);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct sr_context* _sr_ctx;
|
|
||||||
std::list<DevInst*> _devices;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace pv
|
|
||||||
|
|
||||||
#endif // DSVIEW_PV_DEVICEMANAGER_H
|
|
@ -31,6 +31,8 @@
|
|||||||
#include "../view/trace.h"
|
#include "../view/trace.h"
|
||||||
#include "../dialogs/dsmessagebox.h"
|
#include "../dialogs/dsmessagebox.h"
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
#include "../sigsession.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -59,7 +61,8 @@ Calibration::Calibration(QWidget *parent) :
|
|||||||
this->setWindowOpacity(0.7);
|
this->setWindowOpacity(0.7);
|
||||||
this->setModal(false);
|
this->setModal(false);
|
||||||
|
|
||||||
_dev_inst = NULL;
|
_device_agent = AppControl::Instance()->GetSession()->get_device();
|
||||||
|
|
||||||
_save_btn = new QPushButton(this);
|
_save_btn = new QPushButton(this);
|
||||||
_abort_btn = new QPushButton(this);
|
_abort_btn = new QPushButton(this);
|
||||||
_reset_btn = new QPushButton(this);
|
_reset_btn = new QPushButton(this);
|
||||||
@ -120,10 +123,11 @@ void Calibration::retranslateUi()
|
|||||||
setTitle(tr("Manual Calibration"));
|
setTitle(tr("Manual Calibration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calibration::set_device(DevInst *dev_inst)
|
void Calibration::update_device_info()
|
||||||
{
|
{
|
||||||
assert(dev_inst);
|
if (_device_agent->have_instance()){
|
||||||
_dev_inst = dev_inst;
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
for(std::list<QSlider *>::const_iterator i = _slider_list.begin();
|
for(std::list<QSlider *>::const_iterator i = _slider_list.begin();
|
||||||
i != _slider_list.end(); i++) {
|
i != _slider_list.end(); i++) {
|
||||||
@ -131,6 +135,7 @@ void Calibration::set_device(DevInst *dev_inst)
|
|||||||
_flayout->removeWidget((*i));
|
_flayout->removeWidget((*i));
|
||||||
delete (*i);
|
delete (*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
_slider_list.clear();
|
_slider_list.clear();
|
||||||
for(std::list<QLabel *>::const_iterator i = _label_list.begin();
|
for(std::list<QLabel *>::const_iterator i = _label_list.begin();
|
||||||
i != _label_list.end(); i++) {
|
i != _label_list.end(); i++) {
|
||||||
@ -140,23 +145,23 @@ void Calibration::set_device(DevInst *dev_inst)
|
|||||||
}
|
}
|
||||||
_label_list.clear();
|
_label_list.clear();
|
||||||
|
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
|
|
||||||
uint64_t vgain = 0, vgain_default = 0;
|
uint64_t vgain = 0, vgain_default = 0;
|
||||||
uint16_t vgain_range = 0;
|
uint16_t vgain_range = 0;
|
||||||
GVariant* gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN);
|
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain = g_variant_get_uint64(gvar);
|
vgain = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain_default = g_variant_get_uint64(gvar);
|
vgain_default = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain_range = g_variant_get_uint16(gvar);
|
vgain_range = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -174,12 +179,12 @@ void Calibration::set_device(DevInst *dev_inst)
|
|||||||
|
|
||||||
uint64_t voff = 0;
|
uint64_t voff = 0;
|
||||||
uint16_t voff_range = 0;
|
uint16_t voff_range = 0;
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_PREOFF);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
voff = g_variant_get_uint16(gvar);
|
voff = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
voff_range = g_variant_get_uint16(gvar);
|
voff_range = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -195,14 +200,14 @@ void Calibration::set_device(DevInst *dev_inst)
|
|||||||
_label_list.push_back(off_label);
|
_label_list.push_back(off_label);
|
||||||
|
|
||||||
bool comb_comp_en = false;
|
bool comb_comp_en = false;
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN);
|
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
comb_comp_en = g_variant_get_boolean(gvar);
|
comb_comp_en = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
if (comb_comp_en) {
|
if (comb_comp_en) {
|
||||||
int16_t comb_comp = 0;
|
int16_t comb_comp = 0;
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_COMB_COMP);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_COMB_COMP);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
comb_comp = g_variant_get_int16(gvar);
|
comb_comp = g_variant_get_int16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -229,14 +234,14 @@ void Calibration::set_device(DevInst *dev_inst)
|
|||||||
void Calibration::accept()
|
void Calibration::accept()
|
||||||
{
|
{
|
||||||
using namespace Qt;
|
using namespace Qt;
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false));
|
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false));
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calibration::reject()
|
void Calibration::reject()
|
||||||
{
|
{
|
||||||
using namespace Qt;
|
using namespace Qt;
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false));
|
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false));
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,25 +249,25 @@ void Calibration::set_value(int value)
|
|||||||
{
|
{
|
||||||
QSlider* sc = dynamic_cast<QSlider *>(sender());
|
QSlider* sc = dynamic_cast<QSlider *>(sender());
|
||||||
|
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
if (sc->objectName() == VGAIN+probe->index) {
|
if (sc->objectName() == VGAIN+probe->index) {
|
||||||
uint64_t vgain_default;
|
uint64_t vgain_default;
|
||||||
GVariant* gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain_default = g_variant_get_uint64(gvar);
|
vgain_default = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
_dev_inst->set_config(probe, NULL, SR_CONF_PROBE_VGAIN,
|
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_VGAIN,
|
||||||
g_variant_new_uint64(value+vgain_default));
|
g_variant_new_uint64(value+vgain_default));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (sc->objectName() == VOFF+probe->index) {
|
} else if (sc->objectName() == VOFF+probe->index) {
|
||||||
_dev_inst->set_config(probe, NULL, SR_CONF_PROBE_PREOFF,
|
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_PREOFF,
|
||||||
g_variant_new_uint16(value));
|
g_variant_new_uint16(value));
|
||||||
break;
|
break;
|
||||||
} else if (sc->objectName() == VCOMB+probe->index) {
|
} else if (sc->objectName() == VCOMB+probe->index) {
|
||||||
_dev_inst->set_config(probe, NULL, SR_CONF_PROBE_COMB_COMP,
|
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_COMB_COMP,
|
||||||
g_variant_new_int16(value));
|
g_variant_new_int16(value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -275,7 +280,7 @@ void Calibration::on_save()
|
|||||||
QFuture<void> future;
|
QFuture<void> future;
|
||||||
future = QtConcurrent::run([&]{
|
future = QtConcurrent::run([&]{
|
||||||
//QTime dieTime = QTime::currentTime().addSecs(1);
|
//QTime dieTime = QTime::currentTime().addSecs(1);
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_SET,
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_SET,
|
||||||
g_variant_new_boolean(true));
|
g_variant_new_boolean(true));
|
||||||
//while( QTime::currentTime() < dieTime );
|
//while( QTime::currentTime() < dieTime );
|
||||||
});
|
});
|
||||||
@ -301,7 +306,7 @@ void Calibration::on_abort()
|
|||||||
QFuture<void> future;
|
QFuture<void> future;
|
||||||
future = QtConcurrent::run([&]{
|
future = QtConcurrent::run([&]{
|
||||||
//QTime dieTime = QTime::currentTime().addSecs(1);
|
//QTime dieTime = QTime::currentTime().addSecs(1);
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_LOAD,
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_LOAD,
|
||||||
g_variant_new_boolean(true));
|
g_variant_new_boolean(true));
|
||||||
reload_value();
|
reload_value();
|
||||||
//while( QTime::currentTime() < dieTime );
|
//while( QTime::currentTime() < dieTime );
|
||||||
@ -324,23 +329,23 @@ void Calibration::on_abort()
|
|||||||
|
|
||||||
void Calibration::reload_value()
|
void Calibration::reload_value()
|
||||||
{
|
{
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
|
|
||||||
uint64_t vgain = 0, vgain_default = 0;
|
uint64_t vgain = 0, vgain_default = 0;
|
||||||
uint16_t vgain_range = 0;
|
uint16_t vgain_range = 0;
|
||||||
GVariant* gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN);
|
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain = g_variant_get_uint64(gvar);
|
vgain = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain_default = g_variant_get_uint64(gvar);
|
vgain_default = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vgain_range = g_variant_get_uint16(gvar);
|
vgain_range = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -348,12 +353,12 @@ void Calibration::reload_value()
|
|||||||
|
|
||||||
uint64_t voff = 0;
|
uint64_t voff = 0;
|
||||||
uint16_t voff_range = 0;
|
uint16_t voff_range = 0;
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_PREOFF);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
voff = g_variant_get_uint16(gvar);
|
voff = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN);
|
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
voff_range = g_variant_get_uint16(gvar);
|
voff_range = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -382,7 +387,7 @@ void Calibration::on_reset()
|
|||||||
msg.mBox()->addButton(tr("Cancel"), QMessageBox::RejectRole);
|
msg.mBox()->addButton(tr("Cancel"), QMessageBox::RejectRole);
|
||||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
msg.mBox()->setIcon(QMessageBox::Warning);
|
||||||
if (msg.exec()) {
|
if (msg.exec()) {
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_DEFAULT,
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_DEFAULT,
|
||||||
g_variant_new_boolean(true));
|
g_variant_new_boolean(true));
|
||||||
reload_value();
|
reload_value();
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,13 @@
|
|||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
|
|
||||||
using namespace pv::device;
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
class Calibration : public DSDialog
|
class Calibration : public DSDialog
|
||||||
@ -53,7 +52,8 @@ public:
|
|||||||
Calibration(QWidget *parent);
|
Calibration(QWidget *parent);
|
||||||
~Calibration();
|
~Calibration();
|
||||||
|
|
||||||
void set_device(DevInst *dev_inst);
|
void update_device_info();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
@ -69,9 +69,7 @@ private slots:
|
|||||||
void on_reset();
|
void on_reset();
|
||||||
void reload_value();
|
void reload_value();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevInst *_dev_inst;
|
|
||||||
|
|
||||||
QPushButton *_save_btn;
|
QPushButton *_save_btn;
|
||||||
QPushButton *_abort_btn;
|
QPushButton *_abort_btn;
|
||||||
QPushButton *_reset_btn;
|
QPushButton *_reset_btn;
|
||||||
@ -79,6 +77,8 @@ private:
|
|||||||
QFormLayout *_flayout;
|
QFormLayout *_flayout;
|
||||||
std::list <QSlider *> _slider_list;
|
std::list <QSlider *> _slider_list;
|
||||||
std::list<QLabel *> _label_list;
|
std::list<QLabel *> _label_list;
|
||||||
|
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dialogs
|
} // namespace dialogs
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "decoderoptionsdlg.h"
|
#include "decoderoptionsdlg.h"
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "../prop/property.h"
|
#include "../prop/property.h"
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
#include "../sigsession.h"
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -43,7 +45,7 @@ ChannelLabel::ChannelLabel(IChannelCheck *check, QWidget *parent, int chanIndex)
|
|||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
_checked = check;
|
_checked = check;
|
||||||
_index = chanIndex;
|
_index = chanIndex;
|
||||||
|
|
||||||
this->setFixedSize(30, 40);
|
this->setFixedSize(30, 40);
|
||||||
|
|
||||||
@ -76,10 +78,8 @@ void ChannelLabel::on_checked()
|
|||||||
namespace pv {
|
namespace pv {
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
DeviceOptions::DeviceOptions(QWidget *parent) :
|
||||||
DSDialog(parent),
|
DSDialog(parent)
|
||||||
_dev_inst(dev_inst),
|
|
||||||
_device_options_binding(_dev_inst->dev_inst())
|
|
||||||
{
|
{
|
||||||
_scroll_panel = NULL;
|
_scroll_panel = NULL;
|
||||||
_container_panel = NULL;
|
_container_panel = NULL;
|
||||||
@ -91,6 +91,9 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
|||||||
_container_lay = NULL;
|
_container_lay = NULL;
|
||||||
_isBuilding = false;
|
_isBuilding = false;
|
||||||
|
|
||||||
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
|
_device_agent = session->get_device();
|
||||||
|
|
||||||
this->setTitle(tr("Device Options"));
|
this->setTitle(tr("Device Options"));
|
||||||
this->SetTitleSpace(0);
|
this->SetTitleSpace(0);
|
||||||
this->layout()->setSpacing(0);
|
this->layout()->setSpacing(0);
|
||||||
@ -135,7 +138,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
|||||||
auto button_box = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this);
|
auto button_box = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this);
|
||||||
this->layout()->addWidget(button_box);
|
this->layout()->addWidget(button_box);
|
||||||
|
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -144,8 +147,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
|||||||
try_resize_scroll();
|
try_resize_scroll();
|
||||||
|
|
||||||
connect(&_mode_check, SIGNAL(timeout()), this, SLOT(mode_check()));
|
connect(&_mode_check, SIGNAL(timeout()), this, SLOT(mode_check()));
|
||||||
connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(_dev_inst, SIGNAL(device_updated()), this, SLOT(reject()));
|
|
||||||
|
|
||||||
_mode_check.setInterval(100);
|
_mode_check.setInterval(100);
|
||||||
_mode_check.start();
|
_mode_check.start();
|
||||||
@ -167,10 +169,10 @@ void DeviceOptions::accept()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Commit the probes
|
// Commit the probes
|
||||||
if (_dev_inst->dev_inst()->mode == LOGIC ||
|
int mode = _device_agent->get_work_mode();
|
||||||
_dev_inst->dev_inst()->mode == ANALOG) {
|
if (mode == LOGIC || mode == ANALOG) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
probe->enabled = _probes_checkBox_list.at(index)->isChecked();
|
probe->enabled = _probes_checkBox_list.at(index)->isChecked();
|
||||||
@ -255,13 +257,16 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout)
|
|||||||
_probes_checkBox_list.clear();
|
_probes_checkBox_list.clear();
|
||||||
|
|
||||||
//channel count checked
|
//channel count checked
|
||||||
if (_dev_inst->dev_inst()->mode == LOGIC) {
|
if (_device_agent->get_work_mode()== LOGIC) {
|
||||||
GVariant *gvar_opts;
|
GVariant *gvar_opts;
|
||||||
gsize num_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) {
|
gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_CHANNEL_MODE);
|
||||||
|
|
||||||
|
if (gvar_opts != NULL)
|
||||||
|
{
|
||||||
const char **const options = g_variant_get_strv(gvar_opts, &num_opts);
|
const char **const options = g_variant_get_strv(gvar_opts, &num_opts);
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_CHANNEL_MODE);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_CHANNEL_MODE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
QString ch_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
QString ch_mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -284,7 +289,7 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant *gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vld_ch_num = g_variant_get_int16(gvar);
|
vld_ch_num = g_variant_get_int16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -293,7 +298,7 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout)
|
|||||||
// channels
|
// channels
|
||||||
QHBoxLayout *line_lay = NULL;
|
QHBoxLayout *line_lay = NULL;
|
||||||
|
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
|
|
||||||
@ -373,7 +378,7 @@ void DeviceOptions::enable_max_probes() {
|
|||||||
cur_ch_num++;
|
cur_ch_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
||||||
if (gvar == NULL)
|
if (gvar == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -391,7 +396,7 @@ void DeviceOptions::enable_max_probes() {
|
|||||||
|
|
||||||
void DeviceOptions::enable_all_probes()
|
void DeviceOptions::enable_all_probes()
|
||||||
{
|
{
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_STREAM);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
bool stream_mode = g_variant_get_boolean(gvar);
|
bool stream_mode = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -423,9 +428,9 @@ void DeviceOptions::zero_adj()
|
|||||||
msg.mBox()->setIcon(QMessageBox::Information);
|
msg.mBox()->setIcon(QMessageBox::Information);
|
||||||
|
|
||||||
if (msg.exec()) {
|
if (msg.exec()) {
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(true));
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(true));
|
||||||
} else {
|
} else {
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +438,7 @@ void DeviceOptions::on_calibration()
|
|||||||
{
|
{
|
||||||
using namespace Qt;
|
using namespace Qt;
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(true));
|
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::mode_check()
|
void DeviceOptions::mode_check()
|
||||||
@ -443,7 +448,7 @@ void DeviceOptions::mode_check()
|
|||||||
|
|
||||||
bool test;
|
bool test;
|
||||||
QString mode;
|
QString mode;
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
mode = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -455,7 +460,7 @@ void DeviceOptions::mode_check()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_TEST);
|
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TEST);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
test = g_variant_get_boolean(gvar);
|
test = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -476,7 +481,7 @@ void DeviceOptions::channel_check()
|
|||||||
text.remove('&');
|
text.remove('&');
|
||||||
|
|
||||||
if(sc != NULL){
|
if(sc != NULL){
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(text.toUtf8().data()));
|
_device_agent->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(text.toUtf8().data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
build_dynamic_panel();
|
build_dynamic_panel();
|
||||||
@ -487,11 +492,11 @@ void DeviceOptions::analog_channel_check()
|
|||||||
{
|
{
|
||||||
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
||||||
if(sc != NULL) {
|
if(sc != NULL) {
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
if (sc->property("index").toInt() == probe->index)
|
if (sc->property("index").toInt() == probe->index)
|
||||||
_dev_inst->set_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT,
|
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT,
|
||||||
g_variant_new_boolean(sc->isChecked()));
|
g_variant_new_boolean(sc->isChecked()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,12 +507,12 @@ void DeviceOptions::analog_channel_check()
|
|||||||
|
|
||||||
void DeviceOptions::channel_enable()
|
void DeviceOptions::channel_enable()
|
||||||
{
|
{
|
||||||
if (_dev_inst->dev_inst()->mode == LOGIC) {
|
if (_device_agent->get_work_mode() == LOGIC) {
|
||||||
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
||||||
if (sc == NULL || !sc->isChecked())
|
if (sc == NULL || !sc->isChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_STREAM);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||||
if (gvar == NULL)
|
if (gvar == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -523,7 +528,7 @@ void DeviceOptions::channel_enable()
|
|||||||
cur_ch_num++;
|
cur_ch_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM);
|
||||||
if (gvar == NULL)
|
if (gvar == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -540,7 +545,7 @@ void DeviceOptions::channel_enable()
|
|||||||
sc->setChecked(false);
|
sc->setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_dev_inst->dev_inst()->mode == ANALOG) {
|
else if (_device_agent->get_work_mode() == ANALOG) {
|
||||||
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
QCheckBox* sc=dynamic_cast<QCheckBox*>(sender());
|
||||||
if (sc != NULL) {
|
if (sc != NULL) {
|
||||||
QGridLayout *const layout = (QGridLayout *)sc->property("Layout").value<void *>();
|
QGridLayout *const layout = (QGridLayout *)sc->property("Layout").value<void *>();
|
||||||
@ -568,7 +573,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout)
|
|||||||
tabWidget->setUsesScrollButtons(false);
|
tabWidget->setUsesScrollButtons(false);
|
||||||
//layout.setContentsMargins(0,20, 0, 10);
|
//layout.setContentsMargins(0,20, 0, 10);
|
||||||
|
|
||||||
for (const GSList *l = _dev_inst->dev_inst()->channels; l; l = l->next) {
|
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
|
||||||
sr_channel *const probe = (sr_channel*)l->data;
|
sr_channel *const probe = (sr_channel*)l->data;
|
||||||
assert(probe);
|
assert(probe);
|
||||||
|
|
||||||
@ -589,7 +594,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout)
|
|||||||
probe_layout->addWidget(probe_checkBox, 0, 1, 1, 3);
|
probe_layout->addWidget(probe_checkBox, 0, 1, 1, 3);
|
||||||
|
|
||||||
pv::prop::binding::ProbeOptions *probe_options_binding =
|
pv::prop::binding::ProbeOptions *probe_options_binding =
|
||||||
new pv::prop::binding::ProbeOptions(_dev_inst->dev_inst(), probe);
|
new pv::prop::binding::ProbeOptions(probe);
|
||||||
const auto &properties = probe_options_binding->properties();
|
const auto &properties = probe_options_binding->properties();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
@ -607,7 +612,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout)
|
|||||||
} else {
|
} else {
|
||||||
if (probe_checkBox->isChecked() && p->name().contains("Map")) {
|
if (probe_checkBox->isChecked() && p->name().contains("Map")) {
|
||||||
bool map_default = true;
|
bool map_default = true;
|
||||||
GVariant* gvar = _dev_inst->get_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT);
|
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
map_default =g_variant_get_boolean(gvar);
|
map_default =g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -637,16 +642,18 @@ void DeviceOptions::ChannelChecked(int index)
|
|||||||
channel_enable();
|
channel_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceOptions::dynamic_widget(QLayout *lay) {
|
QString DeviceOptions::dynamic_widget(QLayout *lay)
|
||||||
|
{
|
||||||
|
int mode = _device_agent->get_work_mode();
|
||||||
|
|
||||||
if (_dev_inst->dev_inst()->mode == LOGIC) {
|
if (mode == LOGIC) {
|
||||||
QVBoxLayout *grid = dynamic_cast<QVBoxLayout*>(lay);
|
QVBoxLayout *grid = dynamic_cast<QVBoxLayout*>(lay);
|
||||||
assert(grid);
|
assert(grid);
|
||||||
logic_probes(*grid);
|
logic_probes(*grid);
|
||||||
return tr("Channels");
|
return tr("Channels");
|
||||||
}
|
}
|
||||||
else if (_dev_inst->dev_inst()->mode == DSO) {
|
else if (mode == DSO) {
|
||||||
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_HAVE_ZERO);
|
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_HAVE_ZERO);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
bool have_zero = g_variant_get_boolean(gvar);
|
bool have_zero = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -670,7 +677,7 @@ QString DeviceOptions::dynamic_widget(QLayout *lay) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_dev_inst->dev_inst()->mode == ANALOG) {
|
else if (mode == ANALOG) {
|
||||||
QGridLayout *grid = dynamic_cast<QGridLayout*>(lay);
|
QGridLayout *grid = dynamic_cast<QGridLayout*>(lay);
|
||||||
assert(grid);
|
assert(grid);
|
||||||
analog_probes(*grid);
|
analog_probes(*grid);
|
||||||
@ -693,7 +700,7 @@ void DeviceOptions::build_dynamic_panel()
|
|||||||
_dynamic_panel = new QGroupBox("group", _dynamic_panel);
|
_dynamic_panel = new QGroupBox("group", _dynamic_panel);
|
||||||
_container_lay->addWidget(_dynamic_panel);
|
_container_lay->addWidget(_dynamic_panel);
|
||||||
|
|
||||||
if (_dev_inst->dev_inst()->mode == LOGIC)
|
if (_device_agent->get_work_mode() == LOGIC)
|
||||||
_dynamic_panel->setLayout(new QVBoxLayout());
|
_dynamic_panel->setLayout(new QVBoxLayout());
|
||||||
else
|
else
|
||||||
_dynamic_panel->setLayout(new QGridLayout());
|
_dynamic_panel->setLayout(new QGridLayout());
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#ifndef DSVIEW_PV_DEVICEOPTIONS_H
|
#ifndef DSVIEW_PV_DEVICEOPTIONS_H
|
||||||
#define DSVIEW_PV_DEVICEOPTIONS_H
|
#define DSVIEW_PV_DEVICEOPTIONS_H
|
||||||
|
|
||||||
|
#include <libsigrok.h>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
@ -36,10 +37,7 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "libsigrok.h"
|
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../prop/binding/deviceoptions.h"
|
#include "../prop/binding/deviceoptions.h"
|
||||||
#include "../prop/binding/probeoptions.h"
|
#include "../prop/binding/probeoptions.h"
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
@ -72,9 +70,10 @@ private:
|
|||||||
int _index;
|
int _index;
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace pv::device;
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
class DeviceOptions : public DSDialog, public IChannelCheck
|
class DeviceOptions : public DSDialog, public IChannelCheck
|
||||||
@ -82,7 +81,7 @@ class DeviceOptions : public DSDialog, public IChannelCheck
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeviceOptions(QWidget *parent, DevInst *dev_inst);
|
DeviceOptions(QWidget *parent);
|
||||||
|
|
||||||
~DeviceOptions();
|
~DeviceOptions();
|
||||||
|
|
||||||
@ -116,8 +115,7 @@ private slots:
|
|||||||
void on_calibration();
|
void on_calibration();
|
||||||
void channel_enable();
|
void channel_enable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevInst *_dev_inst;
|
|
||||||
std::vector<QCheckBox *> _probes_checkBox_list;
|
std::vector<QCheckBox *> _probes_checkBox_list;
|
||||||
std::vector<QLayout *> _sub_lays;
|
std::vector<QLayout *> _sub_lays;
|
||||||
|
|
||||||
@ -133,6 +131,7 @@ private:
|
|||||||
int _groupHeight1;
|
int _groupHeight1;
|
||||||
int _groupHeight2;
|
int _groupHeight2;
|
||||||
volatile bool _isBuilding;
|
volatile bool _isBuilding;
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
|
|
||||||
pv::prop::binding::DeviceOptions _device_options_binding;
|
pv::prop::binding::DeviceOptions _device_options_binding;
|
||||||
QVector <pv::prop::binding::ProbeOptions *> _probe_options_binding_list;
|
QVector <pv::prop::binding::ProbeOptions *> _probe_options_binding_list;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "../interface/uicallback.h"
|
#include "../interface/icallbacks.h"
|
||||||
|
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dsomeasure.h"
|
#include "dsomeasure.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ DsoMeasure::DsoMeasure(SigSession *session, View &parent,
|
|||||||
|
|
||||||
connect(_button_box.button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
|
connect(_button_box.button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
connect(_button_box.button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(reset()));
|
connect(_button_box.button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(reset()));
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DsoMeasure::~DsoMeasure(){
|
DsoMeasure::~DsoMeasure(){
|
||||||
|
@ -220,7 +220,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) :
|
|||||||
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
connect(_window_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(window_changed(int)));
|
connect(_window_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(window_changed(int)));
|
||||||
connect(_len_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(len_changed(int)));
|
connect(_len_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(len_changed(int)));
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
FftOptions::~FftOptions(){
|
FftOptions::~FftOptions(){
|
||||||
@ -243,12 +243,13 @@ void FftOptions::accept()
|
|||||||
spectrumTraces->get_spectrum_stack()->set_sample_interval(_interval_combobox->currentData().toInt());
|
spectrumTraces->get_spectrum_stack()->set_sample_interval(_interval_combobox->currentData().toInt());
|
||||||
spectrumTraces->get_spectrum_stack()->set_windows_index(_window_combobox->currentData().toInt());
|
spectrumTraces->get_spectrum_stack()->set_windows_index(_window_combobox->currentData().toInt());
|
||||||
spectrumTraces->set_view_mode(_view_combobox->currentData().toUInt());
|
spectrumTraces->set_view_mode(_view_combobox->currentData().toUInt());
|
||||||
//spectrumTraces->init_zoom();
|
|
||||||
spectrumTraces->set_dbv_range(_dbv_combobox->currentData().toInt());
|
spectrumTraces->set_dbv_range(_dbv_combobox->currentData().toInt());
|
||||||
spectrumTraces->set_enable(_en_checkbox->isChecked());
|
spectrumTraces->set_enable(_en_checkbox->isChecked());
|
||||||
if (_session->get_capture_state() == SigSession::Stopped &&
|
|
||||||
spectrumTraces->enabled())
|
if (_session->is_stopped_status() && spectrumTraces->enabled()){
|
||||||
spectrumTraces->get_spectrum_stack()->calc_fft();
|
spectrumTraces->get_spectrum_stack()->calc_fft();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
#include "../ui/dscombobox.h"
|
#include "../ui/dscombobox.h"
|
||||||
|
@ -26,9 +26,8 @@
|
|||||||
namespace pv {
|
namespace pv {
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
Interval::Interval(SigSession *session, QWidget *parent) :
|
Interval::Interval(QWidget *parent) :
|
||||||
DSDialog(parent),
|
DSDialog(parent),
|
||||||
_session(session),
|
|
||||||
_button_box(QDialogButtonBox::Ok,
|
_button_box(QDialogButtonBox::Ok,
|
||||||
Qt::Horizontal, this)
|
Qt::Horizontal, this)
|
||||||
{
|
{
|
||||||
@ -36,6 +35,7 @@ Interval::Interval(SigSession *session, QWidget *parent) :
|
|||||||
_interval_spinBox = NULL;
|
_interval_spinBox = NULL;
|
||||||
_interval_slider = NULL;
|
_interval_slider = NULL;
|
||||||
_bSetting = false;
|
_bSetting = false;
|
||||||
|
_bDone = false;
|
||||||
|
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
_interval_label = new QLabel(tr("Interval(s): "), this);
|
_interval_label = new QLabel(tr("Interval(s): "), this);
|
||||||
@ -46,9 +46,6 @@ Interval::Interval(SigSession *session, QWidget *parent) :
|
|||||||
_interval_slider = new QSlider(Qt::Horizontal, this);
|
_interval_slider = new QSlider(Qt::Horizontal, this);
|
||||||
_interval_slider->setRange(0, 10);
|
_interval_slider->setRange(0, 10);
|
||||||
|
|
||||||
_interval_slider->setValue((int)_session->get_repeat_intvl());
|
|
||||||
_interval_spinBox->setValue(_session->get_repeat_intvl());
|
|
||||||
|
|
||||||
QGridLayout *glayout = new QGridLayout(this);
|
QGridLayout *glayout = new QGridLayout(this);
|
||||||
glayout->addWidget(_interval_label, 0, 0);
|
glayout->addWidget(_interval_label, 0, 0);
|
||||||
glayout->addWidget(_interval_spinBox, 0, 1);
|
glayout->addWidget(_interval_spinBox, 0, 1);
|
||||||
@ -66,7 +63,7 @@ Interval::Interval(SigSession *session, QWidget *parent) :
|
|||||||
void Interval::accept()
|
void Interval::accept()
|
||||||
{
|
{
|
||||||
using namespace Qt;
|
using namespace Qt;
|
||||||
_session->set_repeat_intvl(_interval_spinBox->value());
|
_bDone = true;
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,14 +74,24 @@ void Interval::reject()
|
|||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Interval::set_interval(double value)
|
||||||
|
{
|
||||||
|
_interval_slider->setValue((int)value);
|
||||||
|
_interval_spinBox->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
double Interval::get_interval()
|
||||||
|
{
|
||||||
|
return _interval_spinBox->value();
|
||||||
|
}
|
||||||
|
|
||||||
void Interval::on_slider_changed(int value)
|
void Interval::on_slider_changed(int value)
|
||||||
{
|
{
|
||||||
if (!_bSetting){
|
if (!_bSetting){
|
||||||
_bSetting = true;
|
_bSetting = true;
|
||||||
_interval_spinBox->setValue((double)value);
|
_interval_spinBox->setValue((double)value);
|
||||||
_bSetting = false;
|
_bSetting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interval::on_inputbox_changed(double value)
|
void Interval::on_inputbox_changed(double value)
|
||||||
@ -93,8 +100,7 @@ void Interval::on_inputbox_changed(double value)
|
|||||||
_bSetting = true;
|
_bSetting = true;
|
||||||
_interval_slider->setValue((int)value);
|
_interval_slider->setValue((int)value);
|
||||||
_bSetting = false;
|
_bSetting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dialogs
|
} // namespace dialogs
|
||||||
|
@ -40,25 +40,31 @@ class Interval : public DSDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Interval(SigSession *session, QWidget *parent);
|
Interval(QWidget *parent);
|
||||||
|
|
||||||
|
void set_interval(double value);
|
||||||
|
double get_interval();
|
||||||
|
|
||||||
|
inline bool is_done(){
|
||||||
|
return _bDone;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void on_slider_changed(int value);
|
void on_slider_changed(int value);
|
||||||
void on_inputbox_changed(double value);
|
void on_inputbox_changed(double value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession *_session;
|
|
||||||
|
|
||||||
QLabel *_interval_label;
|
QLabel *_interval_label;
|
||||||
QDoubleSpinBox *_interval_spinBox;
|
QDoubleSpinBox *_interval_spinBox;
|
||||||
QSlider *_interval_slider;
|
QSlider *_interval_slider;
|
||||||
|
|
||||||
QDialogButtonBox _button_box;
|
QDialogButtonBox _button_box;
|
||||||
bool _bSetting;
|
bool _bSetting;
|
||||||
|
bool _bDone;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dialogs
|
} // namespace dialogs
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lissajousoptions.h"
|
#include "lissajousoptions.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
#include "../view/lissajoustrace.h"
|
#include "../view/lissajoustrace.h"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mathoptions.h"
|
#include "mathoptions.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
#include "../view/mathtrace.h"
|
#include "../view/mathtrace.h"
|
||||||
|
@ -97,7 +97,7 @@ ProtocolExp::ProtocolExp(QWidget *parent, SigSession *session) :
|
|||||||
|
|
||||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../prop/binding/deviceoptions.h"
|
#include "../prop/binding/deviceoptions.h"
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
|
@ -90,7 +90,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession *session) :
|
|||||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(_protocol_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(set_protocol(int)));
|
connect(_protocol_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(set_protocol(int)));
|
||||||
set_protocol(_protocol_combobox->currentIndex());
|
set_protocol(_protocol_combobox->currentIndex());
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../prop/binding/deviceoptions.h"
|
#include "../prop/binding/deviceoptions.h"
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../view/cursor.h"
|
#include "../view/cursor.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -73,7 +72,7 @@ RegionOptions::RegionOptions(view::View *view, SigSession *session, QWidget *par
|
|||||||
setTitle(tr("Region"));
|
setTitle(tr("Region"));
|
||||||
|
|
||||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(set_region()));
|
connect(&_button_box, SIGNAL(accepted()), this, SLOT(set_region()));
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(reject()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ Search::Search(QWidget *parent, SigSession *session, std::map<uint16_t, QString>
|
|||||||
|
|
||||||
connect(&search_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(&search_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(&search_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(&search_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
connect(_session->get_device(), SIGNAL(device_updated()), this, SLOT(reject()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Search::~Search()
|
Search::~Search()
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include "../ui/msgbox.h"
|
#include "../ui/msgbox.h"
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
|
#include "../interface/icallbacks.h"
|
||||||
|
#include "../log.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
@ -122,8 +124,10 @@ void StoreProgress::reject()
|
|||||||
{
|
{
|
||||||
using namespace Qt;
|
using namespace Qt;
|
||||||
_store_session.cancel();
|
_store_session.cancel();
|
||||||
save_done();
|
_store_session.session()->set_saving(false);
|
||||||
|
save_done();
|
||||||
DSDialog::reject();
|
DSDialog::reject();
|
||||||
|
_store_session.session()->broadcast_msg(DSV_MSG_SAVE_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreProgress::accept()
|
void StoreProgress::accept()
|
||||||
@ -157,7 +161,8 @@ void StoreProgress::accept()
|
|||||||
//start done
|
//start done
|
||||||
if (_isExport){
|
if (_isExport){
|
||||||
if (_store_session.export_start()){
|
if (_store_session.export_start()){
|
||||||
QTimer::singleShot(100, this, SLOT(timeout()));
|
_store_session.session()->set_saving(true);
|
||||||
|
QTimer::singleShot(100, this, SLOT(timeout()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
save_done();
|
save_done();
|
||||||
@ -167,7 +172,8 @@ void StoreProgress::accept()
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (_store_session.save_start()){
|
if (_store_session.save_start()){
|
||||||
QTimer::singleShot(100, this, SLOT(timeout()));
|
_store_session.session()->set_saving(true);
|
||||||
|
QTimer::singleShot(100, this, SLOT(timeout()));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
save_done();
|
save_done();
|
||||||
@ -248,9 +254,11 @@ void StoreProgress::show_error()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StoreProgress::closeEvent(QCloseEvent* e)
|
void StoreProgress::closeEvent(QCloseEvent* e)
|
||||||
{
|
{
|
||||||
_store_session.cancel();
|
_store_session.cancel();
|
||||||
|
_store_session.session()->set_saving(false);
|
||||||
DSDialog::closeEvent(e);
|
DSDialog::closeEvent(e);
|
||||||
|
_store_session.session()->broadcast_msg(DSV_MSG_SAVE_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoreProgress::on_progress_updated()
|
void StoreProgress::on_progress_updated()
|
||||||
|
@ -49,7 +49,8 @@ WaitingDialog::WaitingDialog(QWidget *parent, SigSession *session, int key) :
|
|||||||
_button_box(QDialogButtonBox::Abort,
|
_button_box(QDialogButtonBox::Abort,
|
||||||
Qt::Horizontal, this)
|
Qt::Horizontal, this)
|
||||||
{
|
{
|
||||||
_dev_inst = _session->get_device();
|
_device_agent = _session->get_device();
|
||||||
|
|
||||||
this->setFixedSize((GIF_WIDTH+2*TIP_WIDTH)*1.2, (GIF_HEIGHT+2*TIP_HEIGHT)*4);
|
this->setFixedSize((GIF_WIDTH+2*TIP_WIDTH)*1.2, (GIF_HEIGHT+2*TIP_HEIGHT)*4);
|
||||||
this->setWindowOpacity(0.7);
|
this->setWindowOpacity(0.7);
|
||||||
|
|
||||||
@ -78,8 +79,7 @@ WaitingDialog::WaitingDialog(QWidget *parent, SigSession *session, int key) :
|
|||||||
connect(timer, SIGNAL(timeout()), this, SLOT(changeText()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(changeText()));
|
||||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
connect(_dev_inst, SIGNAL(device_updated()), this, SLOT(stop()));
|
connect(_session->device_event_object(), SIGNAL(device_updated()), this, SLOT(stop()));
|
||||||
|
|
||||||
|
|
||||||
QVBoxLayout *mlayout = new QVBoxLayout();
|
QVBoxLayout *mlayout = new QVBoxLayout();
|
||||||
mlayout->addWidget(warning_tips, Qt::AlignHCenter);
|
mlayout->addWidget(warning_tips, Qt::AlignHCenter);
|
||||||
@ -100,7 +100,7 @@ void WaitingDialog::accept()
|
|||||||
|
|
||||||
QFuture<void> future;
|
QFuture<void> future;
|
||||||
future = QtConcurrent::run([&]{
|
future = QtConcurrent::run([&]{
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_SET,
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_SET,
|
||||||
g_variant_new_boolean(true));
|
g_variant_new_boolean(true));
|
||||||
});
|
});
|
||||||
Qt::WindowFlags flags = Qt::CustomizeWindowHint;
|
Qt::WindowFlags flags = Qt::CustomizeWindowHint;
|
||||||
@ -128,8 +128,8 @@ void WaitingDialog::reject()
|
|||||||
|
|
||||||
QFuture<void> future;
|
QFuture<void> future;
|
||||||
future = QtConcurrent::run([&]{
|
future = QtConcurrent::run([&]{
|
||||||
_dev_inst->set_config(NULL, NULL, _key, g_variant_new_boolean(false));
|
_device_agent->set_config(NULL, NULL, _key, g_variant_new_boolean(false));
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_LOAD,
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_LOAD,
|
||||||
g_variant_new_boolean(true));
|
g_variant_new_boolean(true));
|
||||||
});
|
});
|
||||||
Qt::WindowFlags flags = Qt::CustomizeWindowHint;
|
Qt::WindowFlags flags = Qt::CustomizeWindowHint;
|
||||||
@ -174,12 +174,12 @@ void WaitingDialog::changeText()
|
|||||||
bool comb_comp_en = false;
|
bool comb_comp_en = false;
|
||||||
bool zero_fgain = false;
|
bool zero_fgain = false;
|
||||||
|
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN);
|
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
comb_comp_en = g_variant_get_boolean(gvar);
|
comb_comp_en = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
if (comb_comp_en) {
|
if (comb_comp_en) {
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_ZERO_COMB_FGAIN);
|
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO_COMB_FGAIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
zero_fgain = g_variant_get_boolean(gvar);
|
zero_fgain = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -192,13 +192,13 @@ void WaitingDialog::changeText()
|
|||||||
dsoSig->set_enable(dsoSig->get_index() == 0);
|
dsoSig->set_enable(dsoSig->get_index() == 0);
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO_COMB, g_variant_new_boolean(true));
|
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_COMB, g_variant_new_boolean(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, _key);
|
gvar = _device_agent->get_config(NULL, NULL, _key);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
bool zero = g_variant_get_boolean(gvar);
|
bool zero = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "dsdialog.h"
|
#include "dsdialog.h"
|
||||||
|
|
||||||
using namespace pv::device;
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
class WaitingDialog : public DSDialog
|
class WaitingDialog : public DSDialog
|
||||||
@ -67,7 +67,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
int _key;
|
int _key;
|
||||||
SigSession *_session;
|
SigSession *_session;
|
||||||
DevInst* _dev_inst;
|
|
||||||
toolbars::TitleBar *_titlebar;
|
toolbars::TitleBar *_titlebar;
|
||||||
QDialogButtonBox _button_box;
|
QDialogButtonBox _button_box;
|
||||||
|
|
||||||
@ -76,6 +75,7 @@ private:
|
|||||||
QMovie *movie;
|
QMovie *movie;
|
||||||
QTimer *timer;
|
QTimer *timer;
|
||||||
QLabel *tips;
|
QLabel *tips;
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dialogs
|
} // namespace dialogs
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "dsotriggerdock.h"
|
#include "dsotriggerdock.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dialogs/dsmessagebox.h"
|
#include "../dialogs/dsmessagebox.h"
|
||||||
#include "../view/dsosignal.h"
|
#include "../view/dsosignal.h"
|
||||||
|
|
||||||
|
@ -30,10 +30,7 @@
|
|||||||
#include "../view/ruler.h"
|
#include "../view/ruler.h"
|
||||||
#include "../view/logicsignal.h"
|
#include "../view/logicsignal.h"
|
||||||
#include "../data/signaldata.h"
|
#include "../data/signaldata.h"
|
||||||
#include "../data/snapshot.h"
|
#include "../data/snapshot.h"
|
||||||
#include "../devicemanager.h"
|
|
||||||
#include "../device/device.h"
|
|
||||||
#include "../device/file.h"
|
|
||||||
#include "../dialogs/dsdialog.h"
|
#include "../dialogs/dsdialog.h"
|
||||||
#include "../dialogs/dsmessagebox.h"
|
#include "../dialogs/dsmessagebox.h"
|
||||||
|
|
||||||
@ -53,10 +50,8 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession *session) :
|
|||||||
QScrollArea(parent),
|
QScrollArea(parent),
|
||||||
_session(session),
|
_session(session),
|
||||||
_view(view)
|
_view(view)
|
||||||
{
|
{
|
||||||
|
_widget = new QWidget(this);
|
||||||
_widget = new QWidget(this);
|
|
||||||
//_widget->setSizePolicy();
|
|
||||||
|
|
||||||
_mouse_groupBox = new QGroupBox(_widget);
|
_mouse_groupBox = new QGroupBox(_widget);
|
||||||
_fen_checkBox = new QCheckBox(_widget);
|
_fen_checkBox = new QCheckBox(_widget);
|
||||||
@ -211,7 +206,7 @@ void MeasureDock::refresh()
|
|||||||
|
|
||||||
void MeasureDock::reload()
|
void MeasureDock::reload()
|
||||||
{
|
{
|
||||||
if (_session->get_device()->dev_inst()->mode == LOGIC)
|
if (_session->get_device()->get_work_mode() == LOGIC)
|
||||||
_edge_groupBox->setVisible(true);
|
_edge_groupBox->setVisible(true);
|
||||||
else
|
else
|
||||||
_edge_groupBox->setVisible(false);
|
_edge_groupBox->setVisible(false);
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../ui/dscombobox.h"
|
#include "../ui/dscombobox.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
@ -77,8 +77,6 @@ private:
|
|||||||
DsComboBox* create_probe_selector(QWidget *parent);
|
DsComboBox* create_probe_selector(QWidget *parent);
|
||||||
void update_probe_selector(DsComboBox *selector);
|
void update_probe_selector(DsComboBox *selector);
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void goto_cursor();
|
void goto_cursor();
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "protocoldock.h"
|
#include "protocoldock.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../view/decodetrace.h"
|
#include "../view/decodetrace.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../data/decodermodel.h"
|
#include "../data/decodermodel.h"
|
||||||
#include "../data/decoderstack.h"
|
#include "../data/decoderstack.h"
|
||||||
#include "../dialogs/protocollist.h"
|
#include "../dialogs/protocollist.h"
|
||||||
@ -360,13 +359,8 @@ void ProtocolDock::on_add_protocol()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::data::decode::Decoder*> &sub_decoders)
|
bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::data::decode::Decoder*> &sub_decoders)
|
||||||
{
|
{
|
||||||
if (_session->is_device_re_attach() == true){
|
if (_session->get_device()->get_work_mode() != LOGIC) {
|
||||||
dsv_info("%s", "Keep current decoders, cancel add new.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_session->get_device()->dev_inst()->mode != LOGIC) {
|
|
||||||
dsv_info("%s", "Protocol Analyzer\nProtocol Analyzer is only valid in Digital Mode!");
|
dsv_info("%s", "Protocol Analyzer\nProtocol Analyzer is only valid in Digital Mode!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -431,7 +425,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::dat
|
|||||||
|
|
||||||
void ProtocolDock::del_all_protocol()
|
void ProtocolDock::del_all_protocol()
|
||||||
{
|
{
|
||||||
if (_protocol_lay_items.size() > 0 && _session->is_device_re_attach() == false)
|
if (_protocol_lay_items.size() > 0)
|
||||||
{
|
{
|
||||||
_session->clear_all_decoder();
|
_session->clear_all_decoder();
|
||||||
|
|
||||||
@ -1002,7 +996,6 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
|
|||||||
_selected_protocol_id = QString(dec->id);
|
_selected_protocol_id = QString(dec->id);
|
||||||
this->on_add_protocol();
|
this->on_add_protocol();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dock
|
} // namespace dock
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#ifndef DSVIEW_PV_PROTOCOLDOCK_H
|
#ifndef DSVIEW_PV_PROTOCOLDOCK_H
|
||||||
#define DSVIEW_PV_PROTOCOLDOCK_H
|
#define DSVIEW_PV_PROTOCOLDOCK_H
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -44,7 +44,7 @@
|
|||||||
#include "../data/decodermodel.h"
|
#include "../data/decodermodel.h"
|
||||||
#include "protocolitemlayer.h"
|
#include "protocolitemlayer.h"
|
||||||
#include "keywordlineedit.h"
|
#include "keywordlineedit.h"
|
||||||
#include "searchcombobox.h"
|
#include "searchcombobox.h"
|
||||||
|
|
||||||
struct DecoderInfoItem{
|
struct DecoderInfoItem{
|
||||||
void *_data_handle; //srd_decoder* type
|
void *_data_handle; //srd_decoder* type
|
||||||
@ -88,13 +88,14 @@ private:
|
|||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void reStyle();
|
void reStyle();
|
||||||
|
|
||||||
protected:
|
|
||||||
int get_protocol_index_by_id(QString id);
|
int get_protocol_index_by_id(QString id);
|
||||||
static QString parse_protocol_id(const char *id);
|
static QString parse_protocol_id(const char *id);
|
||||||
int get_output_protocol_by_id(QString id);
|
int get_output_protocol_by_id(QString id);
|
||||||
|
|
||||||
private:
|
static int decoder_name_cmp(const void *a, const void *b);
|
||||||
|
void resize_table_view(data::DecoderModel *decoder_model);
|
||||||
|
static bool protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2);
|
||||||
|
|
||||||
//IProtocolItemLayerCallback
|
//IProtocolItemLayerCallback
|
||||||
void OnProtocolSetting(void *handle);
|
void OnProtocolSetting(void *handle);
|
||||||
void OnProtocolDelete(void *handle);
|
void OnProtocolDelete(void *handle);
|
||||||
@ -104,7 +105,7 @@ private:
|
|||||||
void BeginEditKeyword();
|
void BeginEditKeyword();
|
||||||
|
|
||||||
//ISearchItemClick
|
//ISearchItemClick
|
||||||
void OnItemClick(void *sender, void *data_handle);
|
void OnItemClick(void *sender, void *data_handle);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void protocol_updated();
|
void protocol_updated();
|
||||||
@ -127,11 +128,6 @@ private slots:
|
|||||||
void search_changed();
|
void search_changed();
|
||||||
void search_update();
|
void search_update();
|
||||||
void show_protocol_select();
|
void show_protocol_select();
|
||||||
|
|
||||||
private:
|
|
||||||
static int decoder_name_cmp(const void *a, const void *b);
|
|
||||||
void resize_table_view(data::DecoderModel *decoder_model);
|
|
||||||
static bool protocol_sort_callback(const DecoderInfoItem *o1, const DecoderInfoItem *o2);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession *_session;
|
SigSession *_session;
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "../dialogs/search.h"
|
#include "../dialogs/search.h"
|
||||||
#include "../data/snapshot.h"
|
#include "../data/snapshot.h"
|
||||||
#include "../data/logicsnapshot.h"
|
#include "../data/logicsnapshot.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dialogs/dsmessagebox.h"
|
#include "../dialogs/dsmessagebox.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -51,12 +50,7 @@ SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) :
|
|||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
_session(session),
|
_session(session),
|
||||||
_view(view)
|
_view(view)
|
||||||
{
|
{
|
||||||
connect(&_pre_button, SIGNAL(clicked()),
|
|
||||||
this, SLOT(on_previous()));
|
|
||||||
connect(&_nxt_button, SIGNAL(clicked()),
|
|
||||||
this, SLOT(on_next()));
|
|
||||||
|
|
||||||
_search_button = new QPushButton(this);
|
_search_button = new QPushButton(this);
|
||||||
_search_button->setFixedWidth(_search_button->height());
|
_search_button->setFixedWidth(_search_button->height());
|
||||||
_search_button->setDisabled(true);
|
_search_button->setDisabled(true);
|
||||||
@ -85,6 +79,9 @@ SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) :
|
|||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
|
||||||
|
connect(&_pre_button, SIGNAL(clicked()), this, SLOT(on_previous()));
|
||||||
|
connect(&_nxt_button, SIGNAL(clicked()),this, SLOT(on_next()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchDock::~SearchDock()
|
SearchDock::~SearchDock()
|
||||||
@ -248,6 +245,8 @@ void SearchDock::on_next()
|
|||||||
void SearchDock::on_set()
|
void SearchDock::on_set()
|
||||||
{
|
{
|
||||||
dialogs::Search dlg(this, _session, _pattern);
|
dialogs::Search dlg(this, _session, _pattern);
|
||||||
|
connect(_session->device_event_object(), SIGNAL(device_updated()), &dlg, SLOT(reject()));
|
||||||
|
|
||||||
if (dlg.exec()) {
|
if (dlg.exec()) {
|
||||||
std::map<uint16_t, QString> new_pattern = dlg.get_pattern();
|
std::map<uint16_t, QString> new_pattern = dlg.get_pattern();
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ public:
|
|||||||
~SearchDock();
|
~SearchDock();
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "triggerdock.h"
|
#include "triggerdock.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dialogs/dsmessagebox.h"
|
#include "../dialogs/dsmessagebox.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
|
|
||||||
@ -34,8 +33,10 @@
|
|||||||
#include <QInputMethodEvent>
|
#include <QInputMethodEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <libsigrok.h>
|
||||||
#include "libsigrok.h"
|
#include "../config/appconfig.h"
|
||||||
|
#include "../deviceagent.h"
|
||||||
|
#include "../view/logicsignal.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace dock {
|
namespace dock {
|
||||||
@ -46,8 +47,9 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) :
|
|||||||
QScrollArea(parent),
|
QScrollArea(parent),
|
||||||
_session(session)
|
_session(session)
|
||||||
{
|
{
|
||||||
|
|
||||||
_cur_ch_num = 16;
|
_cur_ch_num = 16;
|
||||||
if (_session->get_device()) {
|
if (_session->get_device()->have_instance()) {
|
||||||
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TOTAL_CH_NUM);
|
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TOTAL_CH_NUM);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_cur_ch_num = g_variant_get_int16(gvar);
|
_cur_ch_num = g_variant_get_int16(gvar);
|
||||||
@ -252,11 +254,13 @@ void TriggerDock::device_updated()
|
|||||||
uint8_t maxRange;
|
uint8_t maxRange;
|
||||||
uint64_t sample_limits;
|
uint64_t sample_limits;
|
||||||
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_HW_DEPTH);
|
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_HW_DEPTH);
|
||||||
|
int mode = _session->get_device()->get_work_mode();
|
||||||
|
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
hw_depth = g_variant_get_uint64(gvar);
|
hw_depth = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
|
|
||||||
if (_session->get_device()->dev_inst()->mode == LOGIC) {
|
if (mode == LOGIC) {
|
||||||
|
|
||||||
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
|
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
@ -303,8 +307,9 @@ bool TriggerDock::commit_trigger()
|
|||||||
// trigger mode update
|
// trigger mode update
|
||||||
if (_simple_radioButton->isChecked()) {
|
if (_simple_radioButton->isChecked()) {
|
||||||
ds_trigger_set_mode(SIMPLE_TRIGGER);
|
ds_trigger_set_mode(SIMPLE_TRIGGER);
|
||||||
return 0;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ds_trigger_set_en(true);
|
ds_trigger_set_en(true);
|
||||||
if (_adv_tabWidget->currentIndex() == 0)
|
if (_adv_tabWidget->currentIndex() == 0)
|
||||||
ds_trigger_set_mode(ADV_TRIGGER);
|
ds_trigger_set_mode(ADV_TRIGGER);
|
||||||
@ -396,7 +401,7 @@ bool TriggerDock::commit_trigger()
|
|||||||
_serial_bits_comboBox->currentText().toInt() - 1,
|
_serial_bits_comboBox->currentText().toInt() - 1,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,5 +889,66 @@ void TriggerDock::lineEdit_highlight(QLineEdit *dst) {
|
|||||||
QCoreApplication::sendEvent(dst, &event);
|
QCoreApplication::sendEvent(dst, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerDock::try_commit_trigger()
|
||||||
|
{
|
||||||
|
AppConfig &app = AppConfig::Instance();
|
||||||
|
int num = 0;
|
||||||
|
|
||||||
|
int mode = _session->get_device()->get_work_mode();
|
||||||
|
bool bInstant = _session->is_instant();
|
||||||
|
|
||||||
|
ds_trigger_reset();
|
||||||
|
|
||||||
|
if (mode != LOGIC || bInstant){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commit_trigger() == false)
|
||||||
|
{
|
||||||
|
/* simple trigger check trigger_enable */
|
||||||
|
for(auto &s : _session->get_signals())
|
||||||
|
{
|
||||||
|
assert(s);
|
||||||
|
view::LogicSignal *logicSig = NULL;
|
||||||
|
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
|
||||||
|
if (logicSig->commit_trig())
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app._appOptions.warnofMultiTrig && num > 1) {
|
||||||
|
dialogs::DSMessageBox msg(this);
|
||||||
|
msg.mBox()->setText(tr("Trigger"));
|
||||||
|
msg.mBox()->setInformativeText(tr("Trigger setted on multiple channels! "
|
||||||
|
"Capture will Only triggered when all setted channels fullfill at one sample"));
|
||||||
|
msg.mBox()->setIcon(QMessageBox::Information);
|
||||||
|
|
||||||
|
QPushButton *noMoreButton = msg.mBox()->addButton(tr("Not Show Again"), QMessageBox::ActionRole);
|
||||||
|
QPushButton *cancelButton = msg.mBox()->addButton(tr("Clear Trig"), QMessageBox::ActionRole);
|
||||||
|
msg.mBox()->addButton(tr("Continue"), QMessageBox::ActionRole);
|
||||||
|
|
||||||
|
msg.exec();
|
||||||
|
|
||||||
|
if (msg.mBox()->clickedButton() == cancelButton) {
|
||||||
|
for(auto &s : _session->get_signals())
|
||||||
|
{
|
||||||
|
assert(s);
|
||||||
|
view::LogicSignal *logicSig = NULL;
|
||||||
|
if ((logicSig = dynamic_cast<view::LogicSignal*>(s))) {
|
||||||
|
logicSig->set_trig(view::LogicSignal::NONTRIG);
|
||||||
|
logicSig->commit_trig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.mBox()->clickedButton() == noMoreButton)
|
||||||
|
{
|
||||||
|
app._appOptions.warnofMultiTrig = false;
|
||||||
|
app.SaveApp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dock
|
} // namespace dock
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../ui/dscombobox.h"
|
#include "../ui/dscombobox.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
@ -68,12 +68,10 @@ public:
|
|||||||
QJsonObject get_session();
|
QJsonObject get_session();
|
||||||
void set_session(QJsonObject ses);
|
void set_session(QJsonObject ses);
|
||||||
|
|
||||||
/*
|
void device_updated();
|
||||||
* commit trigger setting
|
|
||||||
* return 0: simple trigger
|
void try_commit_trigger();
|
||||||
* 1: advanced trigger
|
|
||||||
*/
|
|
||||||
bool commit_trigger();
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
@ -82,18 +80,20 @@ private:
|
|||||||
void setup_adv_tab();
|
void setup_adv_tab();
|
||||||
void lineEdit_highlight(QLineEdit *dst);
|
void lineEdit_highlight(QLineEdit *dst);
|
||||||
|
|
||||||
signals:
|
/*
|
||||||
|
* commit trigger setting
|
||||||
|
* return 0: simple trigger
|
||||||
|
* 1: advanced trigger
|
||||||
|
*/
|
||||||
|
bool commit_trigger();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void simple_trigger();
|
void simple_trigger();
|
||||||
void adv_trigger();
|
void adv_trigger();
|
||||||
void widget_enable(int index);
|
void widget_enable(int index);
|
||||||
|
|
||||||
void value_changed();
|
void value_changed();
|
||||||
|
|
||||||
void device_updated();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession *_session;
|
SigSession *_session;
|
||||||
|
@ -36,9 +36,17 @@ void DsTimer::TimeOut(int millsec, CALLBACL_FUNC f)
|
|||||||
{
|
{
|
||||||
_call = f;
|
_call = f;
|
||||||
QTimer::singleShot(millsec, this, SLOT(on_timeout()));
|
QTimer::singleShot(millsec, this, SLOT(on_timeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DsTimer::Start(int millsec, CALLBACL_FUNC f)
|
void DsTimer::TimeOut(int millsec)
|
||||||
|
{
|
||||||
|
if (_call == NULL){
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
QTimer::singleShot(millsec, this, SLOT(on_timeout()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DsTimer::Start(int millsec, CALLBACL_FUNC f)
|
||||||
{
|
{
|
||||||
if (_isActived)
|
if (_isActived)
|
||||||
return;
|
return;
|
||||||
@ -53,7 +61,7 @@ void DsTimer::TimeOut(int millsec, CALLBACL_FUNC f)
|
|||||||
_timer.start(millsec);
|
_timer.start(millsec);
|
||||||
_isActived = true;
|
_isActived = true;
|
||||||
_beginTime = high_resolution_clock::now();
|
_beginTime = high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DsTimer::SetCallback(CALLBACL_FUNC f)
|
void DsTimer::SetCallback(CALLBACL_FUNC f)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,8 @@ public:
|
|||||||
|
|
||||||
void TimeOut(int millsec, CALLBACL_FUNC f);
|
void TimeOut(int millsec, CALLBACL_FUNC f);
|
||||||
|
|
||||||
|
void TimeOut(int millsec);
|
||||||
|
|
||||||
void SetCallback(CALLBACL_FUNC f);
|
void SetCallback(CALLBACL_FUNC f);
|
||||||
|
|
||||||
void Start(int millsec, CALLBACL_FUNC f);
|
void Start(int millsec, CALLBACL_FUNC f);
|
||||||
|
@ -23,4 +23,8 @@
|
|||||||
|
|
||||||
EventObject::EventObject(){
|
EventObject::EventObject(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceEventObject::DeviceEventObject()
|
||||||
|
{
|
||||||
}
|
}
|
@ -36,8 +36,6 @@ signals:
|
|||||||
void show_error(QString error);
|
void show_error(QString error);
|
||||||
void capture_state_changed(int state);
|
void capture_state_changed(int state);
|
||||||
void data_updated();
|
void data_updated();
|
||||||
void device_attach();
|
|
||||||
void device_detach();
|
|
||||||
|
|
||||||
void session_error();
|
void session_error();
|
||||||
void signals_changed();
|
void signals_changed();
|
||||||
@ -48,6 +46,20 @@ signals:
|
|||||||
void decode_done();
|
void decode_done();
|
||||||
void receive_data_len(quint64 len);
|
void receive_data_len(quint64 len);
|
||||||
void cur_snap_samplerate_changed();
|
void cur_snap_samplerate_changed();
|
||||||
|
void trigger_message(int msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceEventObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeviceEventObject();
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void device_updated();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -23,22 +23,17 @@
|
|||||||
#ifndef _I_CALLBACKS_
|
#ifndef _I_CALLBACKS_
|
||||||
#define _I_CALLBACKS_
|
#define _I_CALLBACKS_
|
||||||
|
|
||||||
|
|
||||||
class ISessionCallback
|
class ISessionCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void show_error(QString error)=0;
|
virtual void show_error(QString error)=0;
|
||||||
virtual void session_error()=0;
|
virtual void session_error()=0;
|
||||||
virtual void capture_state_changed(int state)=0;
|
|
||||||
virtual void device_attach()=0;
|
|
||||||
virtual void device_detach()=0;
|
|
||||||
|
|
||||||
virtual void session_save()=0;
|
virtual void session_save()=0;
|
||||||
virtual void data_updated()=0;
|
virtual void data_updated()=0;
|
||||||
virtual void repeat_resume()=0;
|
|
||||||
virtual void update_capture()=0;
|
virtual void update_capture()=0;
|
||||||
virtual void cur_snap_samplerate_changed()=0;
|
|
||||||
|
|
||||||
virtual void device_setted()=0;
|
virtual void cur_snap_samplerate_changed()=0;
|
||||||
virtual void signals_changed()=0;
|
virtual void signals_changed()=0;
|
||||||
virtual void receive_trigger(quint64 trigger_pos)=0;
|
virtual void receive_trigger(quint64 trigger_pos)=0;
|
||||||
virtual void frame_ended()=0;
|
virtual void frame_ended()=0;
|
||||||
@ -52,7 +47,7 @@ public:
|
|||||||
|
|
||||||
virtual void receive_header()=0;
|
virtual void receive_header()=0;
|
||||||
virtual void data_received()=0;
|
virtual void data_received()=0;
|
||||||
|
virtual void trigger_message(int msg)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISessionDataGetter
|
class ISessionDataGetter
|
||||||
@ -61,4 +56,45 @@ public:
|
|||||||
virtual bool genSessionData(std::string &str) = 0;
|
virtual bool genSessionData(std::string &str) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class IDlgCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void OnDlgResult(bool bYes)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IMainForm{
|
||||||
|
public:
|
||||||
|
virtual void switchLanguage(int language)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define DSV_MSG_START_COLLECT_WORK_PREV 5001
|
||||||
|
#define DSV_MSG_START_COLLECT_WORK 5002
|
||||||
|
#define DSV_MSG_COLLECT_START 5003
|
||||||
|
#define DSV_MSG_COLLECT_END 5004
|
||||||
|
#define DSV_MSG_END_COLLECT_WORK_PREV 5005
|
||||||
|
#define DSV_MSG_END_COLLECT_WORK 5006
|
||||||
|
|
||||||
|
#define DSV_MSG_DEVICE_LIST_UPDATED 6000
|
||||||
|
#define DSV_MSG_BEGIN_DEVICE_OPTIONS 6001 //Begin show device options dialog.
|
||||||
|
#define DSV_MSG_END_DEVICE_OPTIONS 6002
|
||||||
|
#define DSV_MSG_DEVICE_OPTIONS_UPDATED 6003
|
||||||
|
#define DSV_MSG_DEVICE_DURATION_UPDATED 6004
|
||||||
|
#define DSV_MSG_DEVICE_MODE_CHANGED 6005
|
||||||
|
#define DSV_MSG_CURRENT_DEVICE_CHANGE_PREV 6006
|
||||||
|
#define DSV_MSG_CURRENT_DEVICE_CHANGED 6007
|
||||||
|
#define DSV_MSG_NEW_USB_DEVICE 6008
|
||||||
|
#define DSV_MSG_CURRENT_DEVICE_DETACHED 6009
|
||||||
|
#define DSV_MSG_DEVICE_CONFIG_UPDATED 6010
|
||||||
|
|
||||||
|
#define DSV_MSG_TRIG_NEXT_COLLECT 7001
|
||||||
|
#define DSV_MSG_SAVE_COMPLETE 7002
|
||||||
|
|
||||||
|
class IMessageListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void OnMessage(int msg)=0;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the DSView project.
|
|
||||||
* DSView is based on PulseView.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 DreamSourceLab <support@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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class IDlgCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void OnDlgResult(bool bYes)=0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class IMainForm{
|
|
||||||
public:
|
|
||||||
virtual void switchLanguage(int language)=0;
|
|
||||||
};
|
|
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include "dialogs/dsmessagebox.h"
|
#include "dialogs/dsmessagebox.h"
|
||||||
#include "interface/icallbacks.h"
|
#include "interface/icallbacks.h"
|
||||||
#include "eventobject.h"
|
#include "eventobject.h"
|
||||||
#include "interface/uicallback.h"
|
#include <QJsonDocument>
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QMenuBar;
|
class QMenuBar;
|
||||||
@ -43,8 +43,11 @@ class QDockWidget;
|
|||||||
|
|
||||||
class AppControl;
|
class AppControl;
|
||||||
|
|
||||||
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
|
class SigSession;
|
||||||
|
|
||||||
namespace toolbars {
|
namespace toolbars {
|
||||||
class SamplingBar;
|
class SamplingBar;
|
||||||
@ -68,12 +71,15 @@ class View;
|
|||||||
namespace device{
|
namespace device{
|
||||||
class DevInst;
|
class DevInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace pv::device;
|
|
||||||
|
|
||||||
//The mainwindow,referenced by MainFrame
|
//The mainwindow,referenced by MainFrame
|
||||||
//TODO: create graph view,toolbar,and show device list
|
//TODO: create graph view,toolbar,and show device list
|
||||||
class MainWindow : public QMainWindow, public ISessionCallback, public IMainForm, public ISessionDataGetter
|
class MainWindow :
|
||||||
|
public QMainWindow,
|
||||||
|
public ISessionCallback,
|
||||||
|
public IMainForm,
|
||||||
|
public ISessionDataGetter,
|
||||||
|
public IMessageListener
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -88,7 +94,8 @@ private:
|
|||||||
void setup_ui();
|
void setup_ui();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
bool load_session_json(QJsonDocument json, bool file_dev,bool bDecoder=true);
|
bool load_session_json(QJsonDocument json, bool &haveDecoder);
|
||||||
|
QString genSessionFileName();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void switchTheme(QString style);
|
void switchTheme(QString style);
|
||||||
@ -96,15 +103,10 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_load_file(QString file_name);
|
void on_load_file(QString file_name);
|
||||||
void on_open_doc();
|
void on_open_doc();
|
||||||
void on_device_updated_reload();
|
|
||||||
void update_device_list();
|
|
||||||
|
|
||||||
void on_run_stop();
|
|
||||||
void on_instant_stop();
|
|
||||||
void on_protocol(bool visible);
|
void on_protocol(bool visible);
|
||||||
void on_trigger(bool visible);
|
void on_trigger(bool visible);
|
||||||
void commit_trigger(bool instant);
|
|
||||||
|
|
||||||
void on_measure(bool visible);
|
void on_measure(bool visible);
|
||||||
void on_search(bool visible);
|
void on_search(bool visible);
|
||||||
@ -113,16 +115,9 @@ private slots:
|
|||||||
|
|
||||||
void on_export();
|
void on_export();
|
||||||
bool on_load_session(QString name);
|
bool on_load_session(QString name);
|
||||||
bool on_store_session(QString name);
|
bool on_store_session(QString name);
|
||||||
void device_detach_post();
|
|
||||||
void device_changed(bool close);
|
|
||||||
void on_device_selected();
|
|
||||||
|
|
||||||
void on_capture_state_changed(int state);
|
|
||||||
void on_data_updated();
|
void on_data_updated();
|
||||||
void on_device_attach();
|
|
||||||
void on_device_detach();
|
|
||||||
void on_show_error(QString str);
|
|
||||||
void on_session_error();
|
void on_session_error();
|
||||||
void on_signals_changed();
|
void on_signals_changed();
|
||||||
void on_receive_trigger(quint64 trigger_pos);
|
void on_receive_trigger(quint64 trigger_pos);
|
||||||
@ -131,6 +126,7 @@ private slots:
|
|||||||
void on_decode_done();
|
void on_decode_done();
|
||||||
void on_receive_data_len(quint64 len);
|
void on_receive_data_len(quint64 len);
|
||||||
void on_cur_snap_samplerate_changed();
|
void on_cur_snap_samplerate_changed();
|
||||||
|
void on_trigger_message(int msg);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void prgRate(int progress);
|
void prgRate(int progress);
|
||||||
@ -143,24 +139,21 @@ public:
|
|||||||
public:
|
public:
|
||||||
void session_save();
|
void session_save();
|
||||||
|
|
||||||
//ISessionDataGetter
|
|
||||||
private:
|
private:
|
||||||
bool genSessionData(std::string &str);
|
void check_usb_device_speed();
|
||||||
|
void reset_all_view();
|
||||||
//ISessionCallback
|
bool confirm_to_store_data();
|
||||||
|
void update_toolbar_view_status();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//ISessionCallback
|
||||||
void show_error(QString error);
|
void show_error(QString error);
|
||||||
void session_error();
|
void session_error();
|
||||||
void capture_state_changed(int state);
|
|
||||||
void device_attach();
|
|
||||||
void device_detach();
|
|
||||||
|
|
||||||
void data_updated();
|
void data_updated();
|
||||||
void repeat_resume();
|
|
||||||
void update_capture();
|
void update_capture();
|
||||||
void cur_snap_samplerate_changed();
|
void cur_snap_samplerate_changed();
|
||||||
void device_setted();
|
|
||||||
|
|
||||||
void signals_changed();
|
void signals_changed();
|
||||||
void receive_trigger(quint64 trigger_pos);
|
void receive_trigger(quint64 trigger_pos);
|
||||||
void frame_ended();
|
void frame_ended();
|
||||||
@ -173,14 +166,20 @@ private:
|
|||||||
void receive_data_len(quint64 len);
|
void receive_data_len(quint64 len);
|
||||||
void receive_header();
|
void receive_header();
|
||||||
void data_received();
|
void data_received();
|
||||||
|
void trigger_message(int msg);
|
||||||
|
|
||||||
//------private
|
//ISessionDataGetter
|
||||||
|
bool genSessionData(std::string &str);
|
||||||
bool gen_session_json(QJsonObject &sessionVar);
|
bool gen_session_json(QJsonObject &sessionVar);
|
||||||
|
void check_session_file_version();
|
||||||
|
void load_device_config();
|
||||||
|
QJsonDocument get_session_json_from_file(QString file);
|
||||||
|
QJsonArray get_decoder_json_from_file(QString file);
|
||||||
|
|
||||||
private:
|
//IMessageListener
|
||||||
AppControl *_control;
|
void OnMessage(int msg);
|
||||||
bool _hot_detach;
|
|
||||||
|
|
||||||
|
private:
|
||||||
pv::view::View *_view;
|
pv::view::View *_view;
|
||||||
dialogs::DSMessageBox *_msg;
|
dialogs::DSMessageBox *_msg;
|
||||||
|
|
||||||
@ -220,8 +219,10 @@ private:
|
|||||||
|
|
||||||
QTranslator _qtTrans;
|
QTranslator _qtTrans;
|
||||||
QTranslator _myTrans;
|
QTranslator _myTrans;
|
||||||
EventObject _event;
|
EventObject _event;
|
||||||
bool _bFirstLoad;
|
SigSession *_session;
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
|
bool _is_auto_switch_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
|
||||||
#include "decoderoptions.h"
|
#include "decoderoptions.h"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#include "../int.h"
|
#include "../int.h"
|
||||||
#include "../../config/appconfig.h"
|
#include "../../config/appconfig.h"
|
||||||
#include "../../log.h"
|
#include "../../log.h"
|
||||||
|
#include "../../appcontrol.h"
|
||||||
|
#include "../../sigsession.h"
|
||||||
|
#include "../../deviceagent.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -38,41 +41,43 @@ namespace pv {
|
|||||||
namespace prop {
|
namespace prop {
|
||||||
namespace binding {
|
namespace binding {
|
||||||
|
|
||||||
DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
|
DeviceOptions::DeviceOptions()
|
||||||
_sdi(sdi)
|
|
||||||
{
|
{
|
||||||
GVariant *gvar_opts, *gvar_list;
|
GVariant *gvar_opts, *gvar_list;
|
||||||
gsize num_opts;
|
gsize num_opts;
|
||||||
|
|
||||||
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS,
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
&gvar_opts) != SR_OK))
|
_device_agent = session->get_device();
|
||||||
|
|
||||||
|
gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_OPTIONS);
|
||||||
|
|
||||||
|
if (gvar_opts == NULL)
|
||||||
/* Driver supports no device instance options. */
|
/* Driver supports no device instance options. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int *const options = (const int32_t *)g_variant_get_fixed_array(
|
const int *const options = (const int32_t *)g_variant_get_fixed_array(
|
||||||
gvar_opts, &num_opts, sizeof(int32_t));
|
gvar_opts, &num_opts, sizeof(int32_t));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < num_opts; i++) {
|
for (unsigned int i = 0; i < num_opts; i++) {
|
||||||
const struct sr_config_info *const info =
|
const struct sr_config_info *const info =
|
||||||
sr_config_info_get(options[i]);
|
_device_agent->get_config_info(options[i]);
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int key = info->key;
|
const int key = info->key;
|
||||||
|
|
||||||
if(sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK)
|
gvar_list = _device_agent->get_config_list(NULL, key);
|
||||||
gvar_list = NULL;
|
|
||||||
|
|
||||||
const QString name(info->name);
|
const QString name(info->name);
|
||||||
char *label_char = info->label;
|
char *label_char = info->label;
|
||||||
GVariant *gvar_tmp = NULL;
|
GVariant *gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_LANGUAGE);
|
||||||
if (sr_config_get(_sdi->driver, _sdi, NULL, NULL, SR_CONF_LANGUAGE, &gvar_tmp) == SR_OK) {
|
|
||||||
if (gvar_tmp != NULL) {
|
if (gvar_tmp != NULL) {
|
||||||
int language = g_variant_get_int16(gvar_tmp);
|
int language = g_variant_get_int16(gvar_tmp);
|
||||||
if (language == LAN_CN)
|
if (language == LAN_CN)
|
||||||
label_char = info->label_cn;
|
label_char = info->label_cn;
|
||||||
g_variant_unref(gvar_tmp);
|
g_variant_unref(gvar_tmp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const QString label(label_char);
|
const QString label(label_char);
|
||||||
|
|
||||||
@ -143,30 +148,25 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
|
|||||||
g_variant_unref(gvar_opts);
|
g_variant_unref(gvar_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant* DeviceOptions::config_getter(
|
GVariant* DeviceOptions::config_getter(int key)
|
||||||
const struct sr_dev_inst *sdi, int key)
|
{
|
||||||
{
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
GVariant *data = NULL;
|
DeviceAgent *_device_agent = session->get_device();
|
||||||
if (sr_config_get(sdi->driver, sdi, NULL, NULL, key, &data) != SR_OK) {
|
return _device_agent->get_config(NULL, NULL, key);
|
||||||
dsv_warn("%s%d", "WARNING: Failed to get value of config id:", key);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::config_setter(
|
void DeviceOptions::config_setter(int key, GVariant* value)
|
||||||
struct sr_dev_inst *sdi, int key, GVariant* value)
|
|
||||||
{
|
{
|
||||||
if (sr_config_set(sdi, NULL, NULL, key, value) != SR_OK){
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
dsv_warn("%s%d", "WARNING: Failed to set value of config id:", key);
|
DeviceAgent *_device_agent = session->get_device();
|
||||||
}
|
_device_agent->set_config(NULL, NULL, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::bind_bool(const QString &name, const QString label, int key)
|
void DeviceOptions::bind_bool(const QString &name, const QString label, int key)
|
||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Bool(name, label, bind(config_getter, _sdi, key),
|
new Bool(name, label, bind(config_getter, key),
|
||||||
bind(config_setter, _sdi, key, _1)));
|
bind(config_setter, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::bind_enum(const QString &name, const QString label, int key,
|
void DeviceOptions::bind_enum(const QString &name, const QString label, int key,
|
||||||
@ -184,8 +184,8 @@ void DeviceOptions::bind_enum(const QString &name, const QString label, int key,
|
|||||||
|
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Enum(name, label, values,
|
new Enum(name, label, values,
|
||||||
bind(config_getter, _sdi, key),
|
bind(config_getter, key),
|
||||||
bind(config_setter, _sdi, key, _1)));
|
bind(config_setter, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
void DeviceOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
||||||
@ -193,8 +193,8 @@ void DeviceOptions::bind_int(const QString &name, const QString label, int key,
|
|||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Int(name, label, suffix, range,
|
new Int(name, label, suffix, range,
|
||||||
bind(config_getter, _sdi, key),
|
bind(config_getter, key),
|
||||||
bind(config_setter, _sdi, key, _1)));
|
bind(config_setter, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
void DeviceOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
||||||
@ -203,16 +203,17 @@ void DeviceOptions::bind_double(const QString &name, const QString label, int ke
|
|||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Double(name, label, decimals, suffix, range, step,
|
new Double(name, label, decimals, suffix, range, step,
|
||||||
bind(config_getter, _sdi, key),
|
bind(config_getter, key),
|
||||||
bind(config_setter, _sdi, key, _1)));
|
bind(config_setter, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceOptions::print_gvariant(GVariant *const gvar)
|
QString DeviceOptions::print_gvariant(GVariant *const gvar)
|
||||||
{
|
{
|
||||||
QString s;
|
QString s;
|
||||||
|
|
||||||
if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s")))
|
if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s"))){
|
||||||
s = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
s = QString::fromUtf8(g_variant_get_string(gvar, NULL));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *const text = g_variant_print(gvar, FALSE);
|
gchar *const text = g_variant_print(gvar, FALSE);
|
||||||
@ -244,8 +245,8 @@ void DeviceOptions::bind_samplerate(const QString &name, const QString label,
|
|||||||
new Double(name, label, 0, QObject::tr("Hz"),
|
new Double(name, label, 0, QObject::tr("Hz"),
|
||||||
make_pair((double)elements[0], (double)elements[1]),
|
make_pair((double)elements[0], (double)elements[1]),
|
||||||
(double)elements[2],
|
(double)elements[2],
|
||||||
bind(samplerate_double_getter, _sdi),
|
bind(samplerate_double_getter),
|
||||||
bind(samplerate_double_setter, _sdi, _1)));
|
bind(samplerate_double_setter, _1)));
|
||||||
|
|
||||||
g_variant_unref(gvar_list_samplerates);
|
g_variant_unref(gvar_list_samplerates);
|
||||||
}
|
}
|
||||||
@ -267,10 +268,9 @@ QString DeviceOptions::print_samplerate(GVariant *const gvar)
|
|||||||
return qstring;
|
return qstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant* DeviceOptions::samplerate_double_getter(
|
GVariant* DeviceOptions::samplerate_double_getter()
|
||||||
const struct sr_dev_inst *sdi)
|
|
||||||
{
|
{
|
||||||
GVariant *const gvar = config_getter(sdi, SR_CONF_SAMPLERATE);
|
GVariant *const gvar = config_getter(SR_CONF_SAMPLERATE);
|
||||||
|
|
||||||
if(!gvar)
|
if(!gvar)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -283,12 +283,11 @@ GVariant* DeviceOptions::samplerate_double_getter(
|
|||||||
return gvar_double;
|
return gvar_double;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceOptions::samplerate_double_setter(
|
void DeviceOptions::samplerate_double_setter(GVariant *value)
|
||||||
struct sr_dev_inst *sdi, GVariant *value)
|
|
||||||
{
|
{
|
||||||
GVariant *const gvar = g_variant_new_uint64(
|
GVariant *const gvar = g_variant_new_uint64(
|
||||||
g_variant_get_double(value));
|
g_variant_get_double(value));
|
||||||
config_setter(sdi, SR_CONF_SAMPLERATE, gvar);
|
config_setter(SR_CONF_SAMPLERATE, gvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceOptions::print_timebase(GVariant *const gvar)
|
QString DeviceOptions::print_timebase(GVariant *const gvar)
|
||||||
@ -315,12 +314,11 @@ void DeviceOptions::bind_bandwidths(const QString &name, const QString label, in
|
|||||||
|
|
||||||
assert(gvar_list);
|
assert(gvar_list);
|
||||||
|
|
||||||
GVariant *gvar_tmp = NULL;
|
GVariant *gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_BANDWIDTH);
|
||||||
if (sr_config_get(_sdi->driver, _sdi, NULL, NULL, SR_CONF_BANDWIDTH, &gvar_tmp) == SR_OK) {
|
|
||||||
if (gvar_tmp != NULL) {
|
if (gvar_tmp != NULL) {
|
||||||
bw_limit = g_variant_get_boolean(gvar_tmp);
|
bw_limit = g_variant_get_boolean(gvar_tmp);
|
||||||
g_variant_unref(gvar_tmp);
|
g_variant_unref(gvar_tmp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bw_limit)
|
if (!bw_limit)
|
||||||
@ -332,8 +330,8 @@ void DeviceOptions::bind_bandwidths(const QString &name, const QString label, in
|
|||||||
|
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Enum(name, label, values,
|
new Enum(name, label, values,
|
||||||
bind(config_getter, _sdi, key),
|
bind(config_getter, key),
|
||||||
bind(config_setter, _sdi, key, _1)));
|
bind(config_setter, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // binding
|
} // binding
|
||||||
|
@ -28,30 +28,32 @@
|
|||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <libsigrok.h>
|
||||||
|
#include "binding.h"
|
||||||
|
|
||||||
#include "libsigrok.h"
|
class DeviceAgent;
|
||||||
#include "binding.h"
|
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
namespace prop {
|
namespace prop {
|
||||||
namespace binding {
|
namespace binding {
|
||||||
|
|
||||||
class DeviceOptions : public Binding
|
class DeviceOptions : public Binding
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeviceOptions(struct sr_dev_inst *sdi);
|
DeviceOptions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static GVariant* config_getter(
|
static GVariant* config_getter(int key);
|
||||||
const struct sr_dev_inst *sdi, int key);
|
|
||||||
static void config_setter(
|
static void config_setter(int key, GVariant* value);
|
||||||
struct sr_dev_inst *sdi, int key, GVariant* value);
|
|
||||||
|
|
||||||
void bind_bool(const QString &name, const QString label, int key);
|
void bind_bool(const QString &name, const QString label, int key);
|
||||||
void bind_enum(const QString &name, const QString label, int key,
|
|
||||||
GVariant *const gvar_list,
|
void bind_enum(const QString &name, const QString label, int key, GVariant *const gvar_list,
|
||||||
boost::function<QString (GVariant*)> printer = print_gvariant);
|
boost::function<QString (GVariant*)> printer = print_gvariant);
|
||||||
|
|
||||||
void bind_int(const QString &name, const QString label, int key, QString suffix,
|
void bind_int(const QString &name, const QString label, int key, QString suffix,
|
||||||
boost::optional< std::pair<int64_t, int64_t> > range);
|
boost::optional< std::pair<int64_t, int64_t> > range);
|
||||||
|
|
||||||
@ -61,23 +63,24 @@ private:
|
|||||||
|
|
||||||
static QString print_gvariant(GVariant *const gvar);
|
static QString print_gvariant(GVariant *const gvar);
|
||||||
|
|
||||||
void bind_samplerate(const QString &name, const QString label,
|
void bind_samplerate(const QString &name, const QString label,GVariant *const gvar_list);
|
||||||
GVariant *const gvar_list);
|
|
||||||
static QString print_samplerate(GVariant *const gvar);
|
static QString print_samplerate(GVariant *const gvar);
|
||||||
static GVariant* samplerate_double_getter(
|
|
||||||
const struct sr_dev_inst *sdi);
|
static GVariant* samplerate_double_getter();
|
||||||
static void samplerate_double_setter(
|
|
||||||
struct sr_dev_inst *sdi, GVariant *value);
|
static void samplerate_double_setter(GVariant *value);
|
||||||
|
|
||||||
static QString print_timebase(GVariant *const gvar);
|
static QString print_timebase(GVariant *const gvar);
|
||||||
|
|
||||||
static QString print_vdiv(GVariant *const gvar);
|
static QString print_vdiv(GVariant *const gvar);
|
||||||
|
|
||||||
void bind_bandwidths(const QString &name, const QString label, int key,
|
void bind_bandwidths(const QString &name, const QString label, int key,GVariant *const gvar_list,
|
||||||
GVariant *const gvar_list,
|
|
||||||
boost::function<QString (GVariant*)> printer = print_gvariant);
|
boost::function<QString (GVariant*)> printer = print_gvariant);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
struct sr_dev_inst *const _sdi;
|
DeviceAgent *_device_agent;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // binding
|
} // binding
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "../int.h"
|
#include "../int.h"
|
||||||
#include "../../config/appconfig.h"
|
#include "../../config/appconfig.h"
|
||||||
#include "../../log.h"
|
#include "../../log.h"
|
||||||
|
#include "../../appcontrol.h"
|
||||||
|
#include "../../sigsession.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -36,43 +38,45 @@ namespace pv {
|
|||||||
namespace prop {
|
namespace prop {
|
||||||
namespace binding {
|
namespace binding {
|
||||||
|
|
||||||
ProbeOptions::ProbeOptions(struct sr_dev_inst *sdi, struct sr_channel *probe) :
|
ProbeOptions::ProbeOptions(struct sr_channel *probe) :
|
||||||
Binding(),
|
Binding(),
|
||||||
_sdi(sdi),
|
|
||||||
_probe(probe)
|
_probe(probe)
|
||||||
{
|
{
|
||||||
GVariant *gvar_opts, *gvar_list;
|
GVariant *gvar_opts, *gvar_list;
|
||||||
gsize num_opts;
|
gsize num_opts;
|
||||||
|
|
||||||
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_PROBE_CONFIGS,
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
&gvar_opts) != SR_OK))
|
_device_agent = session->get_device();
|
||||||
|
|
||||||
|
gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_PROBE_CONFIGS);
|
||||||
|
if (gvar_opts != NULL){
|
||||||
/* Driver supports no device instance options. */
|
/* Driver supports no device instance options. */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int *const options = (const int32_t *)g_variant_get_fixed_array(
|
const int *const options = (const int32_t *)g_variant_get_fixed_array(
|
||||||
gvar_opts, &num_opts, sizeof(int32_t));
|
gvar_opts, &num_opts, sizeof(int32_t));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < num_opts; i++) {
|
for (unsigned int i = 0; i < num_opts; i++) {
|
||||||
const struct sr_config_info *const info =
|
const struct sr_config_info *const info =
|
||||||
sr_config_info_get(options[i]);
|
_device_agent->get_config_info(options[i]);
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int key = info->key;
|
const int key = info->key;
|
||||||
|
|
||||||
if(sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK)
|
gvar_list = _device_agent->get_config_list(NULL, key);
|
||||||
gvar_list = NULL;
|
|
||||||
|
|
||||||
const QString name(info->name);
|
const QString name(info->name);
|
||||||
char *label_char = info->label;
|
char *label_char = info->label;
|
||||||
GVariant *gvar_tmp = NULL;
|
GVariant *gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_LANGUAGE);
|
||||||
if (sr_config_get(_sdi->driver, _sdi, NULL, NULL, SR_CONF_LANGUAGE, &gvar_tmp) == SR_OK) {
|
|
||||||
if (gvar_tmp != NULL) {
|
if (gvar_tmp != NULL) {
|
||||||
int language = g_variant_get_int16(gvar_tmp);
|
int language = g_variant_get_int16(gvar_tmp);
|
||||||
if (language == LAN_CN)
|
if (language == LAN_CN)
|
||||||
label_char = info->label_cn;
|
label_char = info->label_cn;
|
||||||
g_variant_unref(gvar_tmp);
|
g_variant_unref(gvar_tmp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const QString label(label_char);
|
const QString label(label_char);
|
||||||
|
|
||||||
@ -111,32 +115,25 @@ ProbeOptions::ProbeOptions(struct sr_dev_inst *sdi, struct sr_channel *probe) :
|
|||||||
g_variant_unref(gvar_opts);
|
g_variant_unref(gvar_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant* ProbeOptions::config_getter(
|
GVariant* ProbeOptions::config_getter(const struct sr_channel *probe, int key)
|
||||||
const struct sr_dev_inst *sdi,
|
{
|
||||||
const struct sr_channel *probe, int key)
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
{
|
DeviceAgent *_device_agent = session->get_device();
|
||||||
GVariant *data = NULL;
|
return _device_agent->get_config(probe, NULL, key);
|
||||||
if (sr_config_get(sdi->driver, sdi, probe, NULL, key, &data) != SR_OK) {
|
|
||||||
dsv_warn("%s%d", "WARNING: Failed to get value of config id:", key);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::config_setter(
|
void ProbeOptions::config_setter(struct sr_channel *probe, int key, GVariant* value)
|
||||||
struct sr_dev_inst *sdi,
|
|
||||||
struct sr_channel *probe, int key, GVariant* value)
|
|
||||||
{
|
{
|
||||||
if (sr_config_set(sdi, probe, NULL, key, value) != SR_OK){
|
SigSession *session = AppControl::Instance()->GetSession();
|
||||||
dsv_warn("%s", "WARNING: Failed to set value of sample rate");
|
DeviceAgent *_device_agent = session->get_device();
|
||||||
}
|
_device_agent->set_config(probe, NULL, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::bind_bool(const QString &name, const QString label, int key)
|
void ProbeOptions::bind_bool(const QString &name, const QString label, int key)
|
||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Bool(name, label, bind(config_getter, _sdi, _probe, key),
|
new Bool(name, label, bind(config_getter, _probe, key),
|
||||||
bind(config_setter, _sdi, _probe, key, _1)));
|
bind(config_setter, _probe, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::bind_enum(const QString &name, const QString label, int key,
|
void ProbeOptions::bind_enum(const QString &name, const QString label, int key,
|
||||||
@ -154,8 +151,8 @@ void ProbeOptions::bind_enum(const QString &name, const QString label, int key,
|
|||||||
|
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Enum(name, label, values,
|
new Enum(name, label, values,
|
||||||
bind(config_getter, _sdi, _probe, key),
|
bind(config_getter, _probe, key),
|
||||||
bind(config_setter, _sdi, _probe, key, _1)));
|
bind(config_setter, _probe, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
void ProbeOptions::bind_int(const QString &name, const QString label, int key, QString suffix,
|
||||||
@ -163,8 +160,8 @@ void ProbeOptions::bind_int(const QString &name, const QString label, int key, Q
|
|||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Int(name, label, suffix, range,
|
new Int(name, label, suffix, range,
|
||||||
bind(config_getter, _sdi, _probe, key),
|
bind(config_getter, _probe, key),
|
||||||
bind(config_setter, _sdi, _probe, key, _1)));
|
bind(config_setter, _probe, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
void ProbeOptions::bind_double(const QString &name, const QString label, int key, QString suffix,
|
||||||
@ -173,8 +170,8 @@ void ProbeOptions::bind_double(const QString &name, const QString label, int key
|
|||||||
{
|
{
|
||||||
_properties.push_back(
|
_properties.push_back(
|
||||||
new Double(name, label, decimals, suffix, range, step,
|
new Double(name, label, decimals, suffix, range, step,
|
||||||
bind(config_getter, _sdi, _probe, key),
|
bind(config_getter, _probe, key),
|
||||||
bind(config_setter, _sdi, _probe, key, _1)));
|
bind(config_setter, _probe, key, _1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeOptions::bind_vdiv(const QString &name, const QString label,
|
void ProbeOptions::bind_vdiv(const QString &name, const QString label,
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <libsigrok.h>
|
||||||
#include "libsigrok.h"
|
|
||||||
#include "binding.h"
|
#include "binding.h"
|
||||||
|
|
||||||
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace prop {
|
namespace prop {
|
||||||
namespace binding {
|
namespace binding {
|
||||||
@ -38,16 +39,14 @@ namespace binding {
|
|||||||
class ProbeOptions : public Binding
|
class ProbeOptions : public Binding
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProbeOptions(struct sr_dev_inst *sdi,
|
ProbeOptions(struct sr_channel *probe);
|
||||||
struct sr_channel *probe);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static GVariant* config_getter(
|
static GVariant* config_getter(
|
||||||
const struct sr_dev_inst *sdi,
|
|
||||||
const struct sr_channel *probe, int key);
|
const struct sr_channel *probe, int key);
|
||||||
|
|
||||||
static void config_setter(
|
static void config_setter(
|
||||||
struct sr_dev_inst *sdi,
|
|
||||||
struct sr_channel *probe, int key, GVariant* value);
|
struct sr_channel *probe, int key, GVariant* value);
|
||||||
|
|
||||||
void bind_bool(const QString &name, const QString label, int key);
|
void bind_bool(const QString &name, const QString label, int key);
|
||||||
@ -72,8 +71,8 @@ private:
|
|||||||
static QString print_coupling(GVariant *const gvar);
|
static QString print_coupling(GVariant *const gvar);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct sr_dev_inst *const _sdi;
|
|
||||||
struct sr_channel *const _probe;
|
struct sr_channel *const _probe;
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // binding
|
} // binding
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,9 @@
|
|||||||
#include "data/mathstack.h"
|
#include "data/mathstack.h"
|
||||||
#include "interface/icallbacks.h"
|
#include "interface/icallbacks.h"
|
||||||
#include "dstimer.h"
|
#include "dstimer.h"
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
|
#include "deviceagent.h"
|
||||||
|
#include "eventobject.h"
|
||||||
|
|
||||||
|
|
||||||
struct srd_decoder;
|
struct srd_decoder;
|
||||||
@ -47,8 +49,6 @@ typedef std::lock_guard<std::mutex> ds_lock_guard;
|
|||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
class DeviceManager;
|
|
||||||
|
|
||||||
namespace data {
|
namespace data {
|
||||||
class SignalData;
|
class SignalData;
|
||||||
class Snapshot;
|
class Snapshot;
|
||||||
@ -82,10 +82,12 @@ class LissajousTrace;
|
|||||||
class MathTrace;
|
class MathTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace pv::device;
|
using namespace pv::data;
|
||||||
|
|
||||||
//created by MainWindow
|
//created by MainWindow
|
||||||
class SigSession
|
class SigSession:
|
||||||
|
public IMessageListener,
|
||||||
|
public IDeviceAgentCallback
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static constexpr float Oversampling = 2.0f;
|
static constexpr float Oversampling = 2.0f;
|
||||||
@ -96,18 +98,7 @@ public:
|
|||||||
static const int FeedInterval = 50;
|
static const int FeedInterval = 50;
|
||||||
static const int WaitShowTime = 500;
|
static const int WaitShowTime = 500;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum capture_state {
|
|
||||||
Init,
|
|
||||||
Stopped,
|
|
||||||
Running
|
|
||||||
};
|
|
||||||
|
|
||||||
enum run_mode {
|
|
||||||
Single,
|
|
||||||
Repetitive
|
|
||||||
};
|
|
||||||
|
|
||||||
enum error_state {
|
enum error_state {
|
||||||
No_err,
|
No_err,
|
||||||
Hw_err,
|
Hw_err,
|
||||||
@ -118,30 +109,42 @@ public:
|
|||||||
Data_overflow
|
Data_overflow
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum device_status_type{
|
||||||
|
ST_INIT = 0,
|
||||||
|
ST_RUNNING = 1,
|
||||||
|
ST_STOPPED = 2,
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession(SigSession &o);
|
SigSession(SigSession &o);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SigSession(DeviceManager *device_manager);
|
explicit SigSession();
|
||||||
|
|
||||||
~SigSession();
|
~SigSession();
|
||||||
|
|
||||||
DevInst* get_device();
|
inline DeviceAgent* get_device(){
|
||||||
|
return &_device_agent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
bool init();
|
||||||
* Sets device instance that will be used in the next capture session.
|
void uninit();
|
||||||
*/
|
void Open();
|
||||||
void set_device(DevInst *dev_inst);
|
void Close();
|
||||||
|
|
||||||
void set_file(QString name);
|
bool set_default_device();
|
||||||
void close_file(DevInst *dev_inst);
|
bool set_device(ds_device_handle dev_handle);
|
||||||
void set_default_device();
|
bool set_file(QString name);
|
||||||
|
void close_file(ds_device_handle dev_handle);
|
||||||
void release_device(DevInst *dev_inst);
|
bool start_capture(bool instant);
|
||||||
capture_state get_capture_state();
|
void stop_capture();
|
||||||
|
|
||||||
uint64_t cur_samplerate();
|
uint64_t cur_samplerate();
|
||||||
uint64_t cur_snap_samplerate();
|
uint64_t cur_snap_samplerate();
|
||||||
uint64_t cur_samplelimits();
|
|
||||||
|
inline uint64_t cur_samplelimits(){
|
||||||
|
return _cur_samplelimits;
|
||||||
|
}
|
||||||
|
|
||||||
double cur_sampletime();
|
double cur_sampletime();
|
||||||
double cur_snap_sampletime();
|
double cur_snap_sampletime();
|
||||||
@ -149,42 +152,62 @@ public:
|
|||||||
|
|
||||||
void set_cur_snap_samplerate(uint64_t samplerate);
|
void set_cur_snap_samplerate(uint64_t samplerate);
|
||||||
void set_cur_samplelimits(uint64_t samplelimits);
|
void set_cur_samplelimits(uint64_t samplelimits);
|
||||||
void set_session_time(QDateTime time);
|
|
||||||
|
|
||||||
QDateTime get_session_time();
|
inline void set_session_time(QDateTime time){
|
||||||
uint64_t get_trigger_pos();
|
_session_time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDateTime get_session_time(){
|
||||||
|
return _session_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint64_t get_trigger_pos(){
|
||||||
|
return _trigger_pos;
|
||||||
|
}
|
||||||
|
|
||||||
bool get_capture_status(bool &triggered, int &progress);
|
bool get_capture_status(bool &triggered, int &progress);
|
||||||
|
|
||||||
void container_init();
|
|
||||||
std::set<data::SignalData*> get_data();
|
std::set<data::SignalData*> get_data();
|
||||||
std::vector<view::Signal*>& get_signals();
|
std::vector<view::Signal*>& get_signals();
|
||||||
std::vector<view::GroupSignal*>& get_group_signals();
|
std::vector<view::GroupSignal*>& get_group_signals();
|
||||||
|
|
||||||
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus,
|
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus,
|
||||||
std::list<pv::data::decode::Decoder*> &sub_decoders);
|
std::list<pv::data::decode::Decoder*> &sub_decoders);
|
||||||
|
|
||||||
int get_trace_index_by_key_handel(void *handel);
|
int get_trace_index_by_key_handel(void *handel);
|
||||||
void remove_decoder(int index);
|
void remove_decoder(int index);
|
||||||
void remove_decoder_by_key_handel(void *handel);
|
void remove_decoder_by_key_handel(void *handel);
|
||||||
std::vector<view::DecodeTrace*>& get_decode_signals();
|
|
||||||
|
inline std::vector<view::DecodeTrace*>& get_decode_signals(){
|
||||||
|
return _decode_traces;
|
||||||
|
}
|
||||||
|
|
||||||
void rst_decoder(int index);
|
void rst_decoder(int index);
|
||||||
void rst_decoder_by_key_handel(void *handel);
|
void rst_decoder_by_key_handel(void *handel);
|
||||||
|
|
||||||
pv::data::DecoderModel* get_decoder_model();
|
inline pv::data::DecoderModel* get_decoder_model(){
|
||||||
std::vector<view::SpectrumTrace*>& get_spectrum_traces();
|
return _decoder_model;
|
||||||
view::LissajousTrace* get_lissajous_trace();
|
}
|
||||||
view::MathTrace* get_math_trace();
|
|
||||||
|
inline std::vector<view::SpectrumTrace*>& get_spectrum_traces(){
|
||||||
|
return _spectrum_traces;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline view::LissajousTrace* get_lissajous_trace(){
|
||||||
|
return _lissajous_trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline view::MathTrace* get_math_trace(){
|
||||||
|
return _math_trace;
|
||||||
|
}
|
||||||
|
|
||||||
void init_signals();
|
|
||||||
void add_group();
|
void add_group();
|
||||||
void del_group();
|
void del_group();
|
||||||
void start_hotplug_work();
|
uint16_t get_ch_num(int type);
|
||||||
void stop_hotplug_work();
|
|
||||||
uint16_t get_ch_num(int type);
|
inline bool get_data_lock(){
|
||||||
|
return _data_lock;
|
||||||
bool get_instant();
|
}
|
||||||
bool get_data_lock();
|
|
||||||
void data_auto_lock(int lock);
|
void data_auto_lock(int lock);
|
||||||
void data_auto_unlock();
|
void data_auto_unlock();
|
||||||
bool get_data_auto_lock();
|
bool get_data_auto_lock();
|
||||||
@ -198,74 +221,153 @@ public:
|
|||||||
data::MathStack::MathType type);
|
data::MathStack::MathType type);
|
||||||
|
|
||||||
void math_disable();
|
void math_disable();
|
||||||
bool trigd();
|
|
||||||
uint8_t trigd_ch();
|
inline bool trigd(){
|
||||||
|
return _trigger_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint8_t trigd_ch(){
|
||||||
|
return _trigger_ch;
|
||||||
|
}
|
||||||
|
|
||||||
data::Snapshot* get_snapshot(int type);
|
data::Snapshot* get_snapshot(int type);
|
||||||
error_state get_error();
|
|
||||||
void set_error(error_state state);
|
inline error_state get_error(){
|
||||||
|
return _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_error(error_state state){
|
||||||
|
_error = state;
|
||||||
|
}
|
||||||
|
|
||||||
void clear_error();
|
void clear_error();
|
||||||
|
|
||||||
uint64_t get_error_pattern();
|
inline uint64_t get_error_pattern(){
|
||||||
run_mode get_run_mode();
|
return _error_pattern;
|
||||||
void set_run_mode(run_mode mode);
|
}
|
||||||
double get_repeat_intvl();
|
|
||||||
void set_repeat_intvl(double interval);
|
|
||||||
|
|
||||||
bool isRepeating();
|
inline double get_repeat_intvl(){
|
||||||
bool repeat_check();
|
return _repeat_intvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_repeat_intvl(double interval){
|
||||||
|
_repeat_intvl = interval;
|
||||||
|
}
|
||||||
|
|
||||||
int get_repeat_hold();
|
int get_repeat_hold();
|
||||||
int get_map_zoom();
|
|
||||||
void set_save_start(uint64_t start);
|
|
||||||
|
|
||||||
void set_save_end(uint64_t end);
|
inline void set_save_start(uint64_t start){
|
||||||
uint64_t get_save_start();
|
_save_start = start;
|
||||||
uint64_t get_save_end();
|
}
|
||||||
bool get_saving();
|
|
||||||
|
|
||||||
void set_saving(bool saving);
|
inline uint64_t get_save_start(){
|
||||||
void set_stop_scale(float scale);
|
return _save_start;
|
||||||
float stop_scale();
|
}
|
||||||
|
|
||||||
|
inline void set_save_end(uint64_t end){
|
||||||
|
_save_end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint64_t get_save_end(){
|
||||||
|
return _save_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_stop_scale(float scale){
|
||||||
|
_stop_scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float stop_scale(){
|
||||||
|
return _stop_scale;
|
||||||
|
}
|
||||||
|
|
||||||
void exit_capture();
|
|
||||||
sr_dev_inst* get_dev_inst_c();
|
|
||||||
void Open();
|
|
||||||
void Close();
|
|
||||||
void clear_all_decoder(bool bUpdateView = true);
|
void clear_all_decoder(bool bUpdateView = true);
|
||||||
|
|
||||||
inline bool is_closed(){
|
inline bool is_closed(){
|
||||||
return _bClose;
|
return _bClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_instant(){
|
||||||
|
return _is_instant;
|
||||||
|
}
|
||||||
|
|
||||||
inline void set_callback(ISessionCallback *callback){
|
inline void set_callback(ISessionCallback *callback){
|
||||||
_callback = callback;
|
_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
inline bool is_working(){
|
||||||
inline void capture_state_changed(int state){
|
return _is_working;
|
||||||
_callback->capture_state_changed(state);
|
}
|
||||||
|
|
||||||
|
inline bool is_init_status(){
|
||||||
|
return _device_status == ST_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The collect thread is running.
|
||||||
|
inline bool is_running_status(){
|
||||||
|
return _device_status == ST_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_stopped_status(){
|
||||||
|
return _device_status == ST_STOPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_repeat_mode(bool repeat);
|
||||||
|
|
||||||
|
inline bool is_repeat_mode(){
|
||||||
|
return _is_repeat_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_repeating(){
|
||||||
|
return _is_repeat_mode && !_is_instant;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void session_save(){
|
inline void session_save(){
|
||||||
_callback->session_save();
|
_callback->session_save();
|
||||||
}
|
|
||||||
|
|
||||||
inline void repeat_resume(){
|
|
||||||
_callback->repeat_resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void show_region(uint64_t start, uint64_t end, bool keep){
|
inline void show_region(uint64_t start, uint64_t end, bool keep){
|
||||||
_callback->show_region(start, end, keep);
|
_callback->show_region(start, end, keep);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void decode_done(){
|
inline void decode_done(){
|
||||||
_callback->decode_done();
|
_callback->decode_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_sr_context(struct sr_context *ctx){
|
inline bool is_saving(){
|
||||||
_sr_ctx = ctx;
|
return _is_saving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void set_saving(bool flag){
|
||||||
|
_is_saving = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DeviceEventObject* device_event_object(){
|
||||||
|
return &_device_event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reload();
|
||||||
|
void refresh(int holdtime);
|
||||||
|
void check_update();
|
||||||
|
|
||||||
|
inline void set_map_zoom(int index){
|
||||||
|
_map_zoom = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int get_map_zoom(){
|
||||||
|
return _map_zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void auto_end();
|
||||||
|
bool have_hardware_data();
|
||||||
|
struct ds_device_base_info* get_device_list(int &out_count, int &actived_index);
|
||||||
|
void add_msg_listener(IMessageListener *ln);
|
||||||
|
void broadcast_msg(int msg);
|
||||||
|
bool switch_work_mode(int mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool exec_capture();
|
||||||
|
void exit_capture();
|
||||||
|
|
||||||
inline void data_updated(){
|
inline void data_updated(){
|
||||||
_callback->data_updated();
|
_callback->data_updated();
|
||||||
}
|
}
|
||||||
@ -276,27 +378,28 @@ private:
|
|||||||
|
|
||||||
inline void receive_data(quint64 len){
|
inline void receive_data(quint64 len){
|
||||||
_callback->receive_data_len(len);
|
_callback->receive_data_len(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
void set_capture_state(capture_state state);
|
|
||||||
void register_hotplug_callback();
|
|
||||||
void deregister_hotplug_callback();
|
|
||||||
|
|
||||||
void add_decode_task(view::DecodeTrace *trace);
|
void add_decode_task(view::DecodeTrace *trace);
|
||||||
void remove_decode_task(view::DecodeTrace *trace);
|
void remove_decode_task(view::DecodeTrace *trace);
|
||||||
void clear_all_decode_task(int &runningDex);
|
void clear_all_decode_task(int &runningDex);
|
||||||
|
|
||||||
view::DecodeTrace* get_decoder_trace(int index);
|
view::DecodeTrace* get_decoder_trace(int index);
|
||||||
void decode_task_proc();
|
void decode_task_proc();
|
||||||
view::DecodeTrace* get_top_decode_task();
|
view::DecodeTrace* get_top_decode_task();
|
||||||
|
|
||||||
void capture_init();
|
void capture_init();
|
||||||
void data_lock();
|
|
||||||
void data_unlock();
|
|
||||||
void nodata_timeout();
|
void nodata_timeout();
|
||||||
void feed_timeout();
|
void feed_timeout();
|
||||||
void repeat_update();
|
|
||||||
|
void container_init();
|
||||||
|
void init_signals();
|
||||||
|
|
||||||
|
//IMessageListener
|
||||||
|
void OnMessage(int msg);
|
||||||
|
|
||||||
|
//IDeviceAgentCallback
|
||||||
|
void DeviceConfigChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -306,8 +409,7 @@ private:
|
|||||||
* used, or NULL if no input format was selected or
|
* used, or NULL if no input format was selected or
|
||||||
* auto-detected.
|
* auto-detected.
|
||||||
*/
|
*/
|
||||||
static sr_input_format* determine_input_file_format(const std::string &filename);
|
static sr_input_format* determine_input_file_format(const std::string &filename);
|
||||||
void sample_thread_proc(DevInst *dev_inst);
|
|
||||||
|
|
||||||
// data feed
|
// data feed
|
||||||
void feed_in_header(const sr_dev_inst *sdi);
|
void feed_in_header(const sr_dev_inst *sdi);
|
||||||
@ -318,62 +420,33 @@ private:
|
|||||||
void feed_in_dso(const sr_datafeed_dso &dso);
|
void feed_in_dso(const sr_datafeed_dso &dso);
|
||||||
void feed_in_analog(const sr_datafeed_analog &analog);
|
void feed_in_analog(const sr_datafeed_analog &analog);
|
||||||
void data_feed_in(const struct sr_dev_inst *sdi,
|
void data_feed_in(const struct sr_dev_inst *sdi,
|
||||||
const struct sr_datafeed_packet *packet);
|
const struct sr_datafeed_packet *packet);
|
||||||
|
|
||||||
static void data_feed_in_proc(const struct sr_dev_inst *sdi,
|
static void data_feed_callback(const struct sr_dev_inst *sdi,
|
||||||
const struct sr_datafeed_packet *packet, void *cb_data);
|
const struct sr_datafeed_packet *packet);
|
||||||
|
|
||||||
// thread for hotplug
|
static void device_lib_event_callback(int event);
|
||||||
void hotplug_proc();
|
void on_device_lib_event(int event);
|
||||||
|
|
||||||
static void hotplug_callback(void *ctx, void *dev, int event, void *user_data);
|
Snapshot* get_signal_snapshot();
|
||||||
|
|
||||||
void on_hotplug_event(void *ctx, void *dev, int event, void *user_data);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void reload();
|
|
||||||
void refresh(int holdtime);
|
|
||||||
void start_capture(bool instant);
|
|
||||||
void stop_capture();
|
|
||||||
void check_update();
|
|
||||||
void set_repeating(bool repeat);
|
|
||||||
void set_map_zoom(int index);
|
|
||||||
void auto_end();
|
|
||||||
|
|
||||||
inline bool is_device_re_attach(){
|
|
||||||
return _is_device_reattach;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void repeat_capture_wait_timeout();
|
||||||
|
void repeat_wait_prog_timeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceManager *_device_manager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The device instance that will be used in the next capture session.
|
|
||||||
*/
|
|
||||||
DevInst *_dev_inst;
|
|
||||||
mutable std::mutex _sampling_mutex;
|
mutable std::mutex _sampling_mutex;
|
||||||
mutable std::mutex _data_mutex;
|
mutable std::mutex _data_mutex;
|
||||||
mutable std::mutex _decode_task_mutex;
|
mutable std::mutex _decode_task_mutex;
|
||||||
|
|
||||||
std::thread _hotplug_thread;
|
|
||||||
std::thread _sampling_thread;
|
|
||||||
std::thread _decode_thread;
|
std::thread _decode_thread;
|
||||||
|
volatile bool _is_decoding;
|
||||||
volatile bool _bHotplugStop;
|
|
||||||
volatile bool _bDecodeRunning;
|
|
||||||
|
|
||||||
capture_state _capture_state;
|
|
||||||
bool _instant;
|
|
||||||
uint64_t _cur_snap_samplerate;
|
uint64_t _cur_snap_samplerate;
|
||||||
uint64_t _cur_samplelimits;
|
uint64_t _cur_samplelimits;
|
||||||
|
|
||||||
std::vector<view::Signal*> _signals;
|
std::vector<view::Signal*> _signals;
|
||||||
std::vector<view::GroupSignal*> _group_traces;
|
std::vector<view::GroupSignal*> _group_traces;
|
||||||
|
|
||||||
std::vector<view::DecodeTrace*> _decode_traces;
|
std::vector<view::DecodeTrace*> _decode_traces;
|
||||||
std::vector<view::DecodeTrace*> _decode_tasks;
|
std::vector<view::DecodeTrace*> _decode_tasks;
|
||||||
pv::data::DecoderModel *_decoder_model;
|
pv::data::DecoderModel *_decoder_model;
|
||||||
|
|
||||||
std::vector<view::SpectrumTrace*> _spectrum_traces;
|
std::vector<view::SpectrumTrace*> _spectrum_traces;
|
||||||
view::LissajousTrace *_lissajous_trace;
|
view::LissajousTrace *_lissajous_trace;
|
||||||
view::MathTrace *_math_trace;
|
view::MathTrace *_math_trace;
|
||||||
@ -383,12 +456,11 @@ private:
|
|||||||
data::Analog *_analog_data;
|
data::Analog *_analog_data;
|
||||||
data::Group *_group_data;
|
data::Group *_group_data;
|
||||||
int _group_cnt;
|
int _group_cnt;
|
||||||
|
|
||||||
bool _hot_attach;
|
|
||||||
bool _hot_detach;
|
|
||||||
|
|
||||||
DsTimer _feed_timer;
|
DsTimer _feed_timer;
|
||||||
DsTimer _out_timer;
|
DsTimer _out_timer;
|
||||||
|
DsTimer _repeat_timer;
|
||||||
|
DsTimer _repeat_wait_prog_timer;
|
||||||
int _noData_cnt;
|
int _noData_cnt;
|
||||||
bool _data_lock;
|
bool _data_lock;
|
||||||
bool _data_updated;
|
bool _data_updated;
|
||||||
@ -402,28 +474,27 @@ private:
|
|||||||
|
|
||||||
error_state _error;
|
error_state _error;
|
||||||
uint64_t _error_pattern;
|
uint64_t _error_pattern;
|
||||||
|
int _map_zoom;
|
||||||
run_mode _run_mode;
|
|
||||||
double _repeat_intvl;
|
|
||||||
bool _repeating;
|
|
||||||
int _repeat_hold_prg;
|
|
||||||
|
|
||||||
int _map_zoom;
|
|
||||||
|
|
||||||
uint64_t _save_start;
|
|
||||||
uint64_t _save_end;
|
|
||||||
bool _saving;
|
|
||||||
|
|
||||||
bool _dso_feed;
|
bool _dso_feed;
|
||||||
float _stop_scale;
|
float _stop_scale;
|
||||||
bool _bClose;
|
bool _bClose;
|
||||||
struct sr_context *_sr_ctx;
|
|
||||||
volatile bool _is_wait_reattch;
|
uint64_t _save_start;
|
||||||
volatile int _wait_reattch_times;
|
uint64_t _save_end;
|
||||||
bool _is_device_reattach;
|
bool _is_working;
|
||||||
QString _last_device_name;
|
bool _is_repeat_mode;
|
||||||
|
double _repeat_intvl; // The progress wait timer interval.
|
||||||
|
int _repeat_hold_prg; // The time sleep progress
|
||||||
|
int _repeat_wait_prog_step;
|
||||||
|
bool _is_saving;
|
||||||
|
bool _is_instant;
|
||||||
|
int _device_status;
|
||||||
|
|
||||||
|
|
||||||
ISessionCallback *_callback;
|
ISessionCallback *_callback;
|
||||||
|
DeviceAgent _device_agent;
|
||||||
|
std::vector<IMessageListener*> _msg_listeners;
|
||||||
|
DeviceEventObject _device_event;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO: This should not be necessary. Multiple concurrent
|
// TODO: This should not be necessary. Multiple concurrent
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "view/logicsignal.h"
|
#include "view/logicsignal.h"
|
||||||
#include "view/dsosignal.h"
|
#include "view/dsosignal.h"
|
||||||
#include "view/decodetrace.h"
|
#include "view/decodetrace.h"
|
||||||
#include "device/devinst.h"
|
|
||||||
#include "dock/protocoldock.h"
|
#include "dock/protocoldock.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -55,13 +54,12 @@
|
|||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
#include "config/appconfig.h"
|
#include "config/appconfig.h"
|
||||||
#include "dsvdef.h"
|
#include "dsvdef.h"
|
||||||
#include "utility/encoding.h"
|
#include "utility/encoding.h"
|
||||||
#include "utility/path.h"
|
#include "utility/path.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ QList<QString> StoreSession::getSuportedExportFormats(){
|
|||||||
while(*supportedModules){
|
while(*supportedModules){
|
||||||
if(*supportedModules == NULL)
|
if(*supportedModules == NULL)
|
||||||
break;
|
break;
|
||||||
if (_session->get_device()->dev_inst()->mode != LOGIC &&
|
if (_session->get_device()->get_work_mode() != LOGIC &&
|
||||||
strcmp((*supportedModules)->id, "csv"))
|
strcmp((*supportedModules)->id, "csv"))
|
||||||
break;
|
break;
|
||||||
QString format((*supportedModules)->desc);
|
QString format((*supportedModules)->desc);
|
||||||
@ -353,23 +351,22 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
struct sr_status status;
|
struct sr_status status;
|
||||||
const sr_dev_inst *sdi = NULL;
|
const sr_dev_inst *sdi = NULL;
|
||||||
char meta[300] = {0};
|
char meta[300] = {0};
|
||||||
|
|
||||||
sdi = _session->get_device()->dev_inst();
|
|
||||||
|
|
||||||
sprintf(meta, "%s", "[version]\n"); str += meta;
|
sprintf(meta, "%s", "[version]\n"); str += meta;
|
||||||
sprintf(meta, "version = %d\n", File_Version); str += meta;
|
sprintf(meta, "version = %d\n", File_Version); str += meta;
|
||||||
sprintf(meta, "%s", "[header]\n"); str += meta;
|
sprintf(meta, "%s", "[header]\n"); str += meta;
|
||||||
|
|
||||||
if (sdi->driver) {
|
int mode = _session->get_device()->get_work_mode();
|
||||||
sprintf(meta, "driver = %s\n", sdi->driver->name); str += meta;
|
|
||||||
sprintf(meta, "device mode = %d\n", sdi->mode); str += meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* metadata */
|
if (true) {
|
||||||
|
sprintf(meta, "driver = %s\n", _session->get_device()->driver_name().toLocal8Bit().data()); str += meta;
|
||||||
|
sprintf(meta, "device mode = %d\n", mode); str += meta;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(meta, "capturefile = data\n"); str += meta;
|
sprintf(meta, "capturefile = data\n"); str += meta;
|
||||||
sprintf(meta, "total samples = %" PRIu64 "\n", snapshot->get_sample_count()); str += meta;
|
sprintf(meta, "total samples = %" PRIu64 "\n", snapshot->get_sample_count()); str += meta;
|
||||||
|
|
||||||
if (sdi->mode != LOGIC) {
|
if (mode != LOGIC) {
|
||||||
sprintf(meta, "total probes = %d\n", snapshot->get_channel_num()); str += meta;
|
sprintf(meta, "total probes = %d\n", snapshot->get_channel_num()); str += meta;
|
||||||
sprintf(meta, "total blocks = %d\n", snapshot->get_block_num()); str += meta;
|
sprintf(meta, "total blocks = %d\n", snapshot->get_block_num()); str += meta;
|
||||||
}
|
}
|
||||||
@ -377,7 +374,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
data::LogicSnapshot *logic_snapshot = NULL;
|
data::LogicSnapshot *logic_snapshot = NULL;
|
||||||
if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) {
|
if ((logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot))) {
|
||||||
uint16_t to_save_probes = 0;
|
uint16_t to_save_probes = 0;
|
||||||
for (l = sdi->channels; l; l = l->next) {
|
for (l = _session->get_device()->get_channels(); l; l = l->next) {
|
||||||
probe = (struct sr_channel *)l->data;
|
probe = (struct sr_channel *)l->data;
|
||||||
if (probe->enabled && logic_snapshot->has_data(probe->index))
|
if (probe->enabled && logic_snapshot->has_data(probe->index))
|
||||||
to_save_probes++;
|
to_save_probes++;
|
||||||
@ -390,7 +387,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
|
|
||||||
sprintf(meta, "samplerate = %s\n", s); str += meta;
|
sprintf(meta, "samplerate = %s\n", s); str += meta;
|
||||||
|
|
||||||
if (sdi->mode == DSO) {
|
if (mode == DSO) {
|
||||||
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
|
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
|
||||||
@ -427,9 +424,11 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
sprintf(meta, "ref max = %d\n", tmp_u32); str += meta;
|
sprintf(meta, "ref max = %d\n", tmp_u32); str += meta;
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
} else if (sdi->mode == LOGIC) {
|
}
|
||||||
|
else if (mode == LOGIC) {
|
||||||
sprintf(meta, "trigger time = %lld\n", _session->get_session_time().toMSecsSinceEpoch()); str += meta;
|
sprintf(meta, "trigger time = %lld\n", _session->get_session_time().toMSecsSinceEpoch()); str += meta;
|
||||||
} else if (sdi->mode == ANALOG) {
|
}
|
||||||
|
else if (mode == ANALOG) {
|
||||||
data::AnalogSnapshot *analog_snapshot = NULL;
|
data::AnalogSnapshot *analog_snapshot = NULL;
|
||||||
if ((analog_snapshot = dynamic_cast<data::AnalogSnapshot*>(snapshot))) {
|
if ((analog_snapshot = dynamic_cast<data::AnalogSnapshot*>(snapshot))) {
|
||||||
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
|
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
|
||||||
@ -452,17 +451,17 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
|
|
||||||
probecnt = 0;
|
probecnt = 0;
|
||||||
|
|
||||||
for (l = sdi->channels; l; l = l->next) {
|
for (l = _session->get_device()->get_channels(); l; l = l->next) {
|
||||||
|
|
||||||
probe = (struct sr_channel *)l->data;
|
probe = (struct sr_channel *)l->data;
|
||||||
if (!snapshot->has_data(probe->index))
|
if (!snapshot->has_data(probe->index))
|
||||||
continue;
|
continue;
|
||||||
if (sdi->mode == LOGIC && !probe->enabled)
|
if (mode == LOGIC && !probe->enabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (probe->name)
|
if (probe->name)
|
||||||
{
|
{
|
||||||
int sigdex = (sdi->mode == LOGIC) ? probe->index : probecnt;
|
int sigdex = (mode == LOGIC) ? probe->index : probecnt;
|
||||||
sprintf(meta, "probe%d = %s\n", sigdex, probe->name);
|
sprintf(meta, "probe%d = %s\n", sigdex, probe->name);
|
||||||
str += meta;
|
str += meta;
|
||||||
}
|
}
|
||||||
@ -472,7 +471,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
str += meta;
|
str += meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdi->mode == DSO)
|
if (mode == DSO)
|
||||||
{
|
{
|
||||||
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
|
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
|
||||||
str += meta;
|
str += meta;
|
||||||
@ -487,7 +486,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
sprintf(meta, " vTrig%d = %d\n", probecnt, probe->trig_value);
|
sprintf(meta, " vTrig%d = %d\n", probecnt, probe->trig_value);
|
||||||
str += meta;
|
str += meta;
|
||||||
|
|
||||||
if (sr_status_get(sdi, &status, false) == SR_OK)
|
if (_session->get_device()->get_device_status(status, false))
|
||||||
{
|
{
|
||||||
if (probe->index == 0)
|
if (probe->index == 0)
|
||||||
{
|
{
|
||||||
@ -553,7 +552,7 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sdi->mode == ANALOG)
|
else if (mode == ANALOG)
|
||||||
{
|
{
|
||||||
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
|
sprintf(meta, " enable%d = %d\n", probecnt, probe->enabled);
|
||||||
str += meta;
|
str += meta;
|
||||||
@ -669,7 +668,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
|
|||||||
|
|
||||||
struct sr_output output;
|
struct sr_output output;
|
||||||
output.module = (sr_output_module*) _outModule;
|
output.module = (sr_output_module*) _outModule;
|
||||||
output.sdi = _session->get_device()->dev_inst();
|
output.sdi = _session->get_device()->inst();
|
||||||
output.param = NULL;
|
output.param = NULL;
|
||||||
if(_outModule->init)
|
if(_outModule->init)
|
||||||
_outModule->init(&output, params);
|
_outModule->init(&output, params);
|
||||||
@ -686,12 +685,14 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
|
|||||||
struct sr_datafeed_meta meta;
|
struct sr_datafeed_meta meta;
|
||||||
struct sr_config *src;
|
struct sr_config *src;
|
||||||
|
|
||||||
src = sr_config_new(SR_CONF_SAMPLERATE,
|
src = _session->get_device()->new_config(SR_CONF_SAMPLERATE,
|
||||||
g_variant_new_uint64(_session->cur_snap_samplerate()));
|
g_variant_new_uint64(_session->cur_snap_samplerate()));
|
||||||
|
|
||||||
meta.config = g_slist_append(NULL, src);
|
meta.config = g_slist_append(NULL, src);
|
||||||
|
|
||||||
src = sr_config_new(SR_CONF_LIMIT_SAMPLES,
|
src = _session->get_device()->new_config(SR_CONF_LIMIT_SAMPLES,
|
||||||
g_variant_new_uint64(snapshot->get_sample_count()));
|
g_variant_new_uint64(snapshot->get_sample_count()));
|
||||||
|
|
||||||
meta.config = g_slist_append(meta.config, src);
|
meta.config = g_slist_append(meta.config, src);
|
||||||
|
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
@ -702,19 +703,24 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
|
|||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
}
|
}
|
||||||
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
||||||
|
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
src = sr_config_new(SR_CONF_REF_MIN, gvar);
|
src = _session->get_device()->new_config(SR_CONF_REF_MIN, gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
} else {
|
}
|
||||||
src = sr_config_new(SR_CONF_REF_MIN, g_variant_new_uint32(1));
|
else {
|
||||||
|
src = _session->get_device()->new_config(SR_CONF_REF_MIN, g_variant_new_uint32(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.config = g_slist_append(meta.config, src);
|
meta.config = g_slist_append(meta.config, src);
|
||||||
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
||||||
|
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
src = sr_config_new(SR_CONF_REF_MAX, gvar);
|
src = _session->get_device()->new_config(SR_CONF_REF_MAX, gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
} else {
|
}
|
||||||
src = sr_config_new(SR_CONF_REF_MAX, g_variant_new_uint32((1 << bits) - 1));
|
else {
|
||||||
|
src = _session->get_device()->new_config(SR_CONF_REF_MAX, g_variant_new_uint32((1 << bits) - 1));
|
||||||
}
|
}
|
||||||
meta.config = g_slist_append(meta.config, src);
|
meta.config = g_slist_append(meta.config, src);
|
||||||
|
|
||||||
@ -729,7 +735,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
|
|||||||
}
|
}
|
||||||
for (GSList *l = meta.config; l; l = l->next) {
|
for (GSList *l = meta.config; l; l = l->next) {
|
||||||
src = (struct sr_config *)l->data;
|
src = (struct sr_config *)l->data;
|
||||||
sr_config_free(src);
|
_session->get_device()->free_config(src);
|
||||||
}
|
}
|
||||||
g_slist_free(meta.config);
|
g_slist_free(meta.config);
|
||||||
|
|
||||||
@ -963,16 +969,16 @@ bool StoreSession::json_decoders(QJsonArray &array)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray dec_array)
|
bool StoreSession::load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_array)
|
||||||
{
|
{
|
||||||
if (_session->get_device()->dev_inst()->mode != LOGIC)
|
if (_session->get_device()->get_work_mode() != LOGIC)
|
||||||
{
|
{
|
||||||
dsv_info("%s", "StoreSession::load_decoders(), is not LOGIC mode.");
|
dsv_info("%s", "StoreSession::load_decoders(), is not LOGIC mode.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dec_array.empty()){
|
if (dec_array.isEmpty()){
|
||||||
dsv_info("%s", "StoreSession::load_decoders(), json object is array empty.");
|
dsv_info("%s", "StoreSession::load_decoders(), json object array is empty.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,10 +1209,10 @@ QString StoreSession::MakeSaveFile(bool bDlg)
|
|||||||
default_name = _root + "/" + _session->get_device()->name() + "-";
|
default_name = _root + "/" + _session->get_device()->name() + "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const GSList *l = _session->get_device()->get_dev_mode_list();
|
for (const GSList *l = _session->get_device()->get_device_mode_list(); l; l = l->next)
|
||||||
l; l = l->next) {
|
{
|
||||||
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
||||||
if (_session->get_device()->dev_inst()->mode == mode->mode) {
|
if (_session->get_device()->get_work_mode() == mode->mode) {
|
||||||
default_name += mode->acronym;
|
default_name += mode->acronym;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1261,10 +1267,9 @@ QString StoreSession::MakeExportFile(bool bDlg)
|
|||||||
default_name = _root + "/" + _session->get_device()->name() + "-";
|
default_name = _root + "/" + _session->get_device()->name() + "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const GSList *l = _session->get_device()->get_dev_mode_list();
|
for (const GSList *l = _session->get_device()->get_device_mode_list(); l; l = l->next) {
|
||||||
l; l = l->next) {
|
|
||||||
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
||||||
if (_session->get_device()->dev_inst()->mode == mode->mode) {
|
if (_session->get_device()->get_work_mode() == mode->mode) {
|
||||||
default_name += mode->acronym;
|
default_name += mode->acronym;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
|
|
||||||
#include "interface/icallbacks.h"
|
#include "interface/icallbacks.h"
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool json_decoders(QJsonArray &array);
|
bool json_decoders(QJsonArray &array);
|
||||||
bool load_decoders(dock::ProtocolDock *widget, QJsonArray dec_array);
|
bool load_decoders(dock::ProtocolDock *widget, QJsonArray &dec_array);
|
||||||
QString MakeSaveFile(bool bDlg);
|
QString MakeSaveFile(bool bDlg);
|
||||||
QString MakeExportFile(bool bDlg);
|
QString MakeExportFile(bool bDlg);
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "filebar.h"
|
#include "filebar.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../ui/msgbox.h"
|
#include "../ui/msgbox.h"
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
#include "../utility/path.h"
|
#include "../utility/path.h"
|
||||||
@ -36,7 +35,6 @@ namespace toolbars {
|
|||||||
|
|
||||||
FileBar::FileBar(SigSession *session, QWidget *parent) :
|
FileBar::FileBar(SigSession *session, QWidget *parent) :
|
||||||
QToolBar("File Bar", parent),
|
QToolBar("File Bar", parent),
|
||||||
_enable(true),
|
|
||||||
_session(session),
|
_session(session),
|
||||||
_file_button(this)
|
_file_button(this)
|
||||||
{
|
{
|
||||||
@ -136,6 +134,13 @@ void FileBar::on_actionOpen_triggered()
|
|||||||
//open data file
|
//open data file
|
||||||
AppConfig &app = AppConfig::Instance();
|
AppConfig &app = AppConfig::Instance();
|
||||||
|
|
||||||
|
if (_session->have_hardware_data()){
|
||||||
|
if (MsgBox::Confirm(tr("Save captured data?"))){
|
||||||
|
sig_save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
const QString file_name = QFileDialog::getOpenFileName(
|
const QString file_name = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
@ -154,21 +159,6 @@ void FileBar::on_actionOpen_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBar::session_error(
|
|
||||||
const QString text, const QString info_text)
|
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod(this, "show_session_error",
|
|
||||||
Qt::QueuedConnection, Q_ARG(QString, text),
|
|
||||||
Q_ARG(QString, info_text));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBar::show_session_error(
|
|
||||||
const QString text, const QString info_text)
|
|
||||||
{
|
|
||||||
(void)text;
|
|
||||||
MsgBox::Show(NULL, info_text.toStdString().c_str(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBar::on_actionLoad_triggered()
|
void FileBar::on_actionLoad_triggered()
|
||||||
{
|
{
|
||||||
//load session file
|
//load session file
|
||||||
@ -200,7 +190,7 @@ void FileBar::on_actionDefault_triggered()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString driver_name = _session->get_device()->name();
|
QString driver_name = _session->get_device()->name();
|
||||||
QString mode_name = QString::number(_session->get_device()->dev_inst()->mode);
|
QString mode_name = QString::number(_session->get_device()->get_work_mode());
|
||||||
int language = LAN_EN;
|
int language = LAN_EN;
|
||||||
GVariant *gvar_tmp = _session->get_device()->get_config(NULL, NULL, SR_CONF_LANGUAGE);
|
GVariant *gvar_tmp = _session->get_device()->get_config(NULL, NULL, SR_CONF_LANGUAGE);
|
||||||
if (gvar_tmp != NULL) {
|
if (gvar_tmp != NULL) {
|
||||||
@ -247,14 +237,12 @@ void FileBar::on_actionCapture_triggered()
|
|||||||
QTimer::singleShot(100, this, SIGNAL(sig_screenShot()));
|
QTimer::singleShot(100, this, SIGNAL(sig_screenShot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBar::enable_toggle(bool enable)
|
void FileBar::update_view_status()
|
||||||
{
|
{
|
||||||
_file_button.setDisabled(!enable);
|
bool bEnable = _session->is_working() == false;
|
||||||
}
|
bool is_hardware = _session->get_device()->is_hardware();
|
||||||
|
_file_button.setEnabled(bEnable);
|
||||||
void FileBar::set_settings_en(bool enable)
|
_menu_session->setEnabled(bEnable && is_hardware);
|
||||||
{
|
|
||||||
_menu_session->setDisabled(!enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace toolbars
|
} // namespace toolbars
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace toolbars {
|
namespace toolbars {
|
||||||
@ -42,19 +42,12 @@ class FileBar : public QToolBar
|
|||||||
public:
|
public:
|
||||||
explicit FileBar(SigSession *session, QWidget *parent = 0);
|
explicit FileBar(SigSession *session, QWidget *parent = 0);
|
||||||
|
|
||||||
void enable_toggle(bool enable);
|
void update_view_status();
|
||||||
|
|
||||||
void set_settings_en(bool enable);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void reStyle();
|
void reStyle();
|
||||||
|
|
||||||
void session_error(
|
|
||||||
const QString text, const QString info_text);
|
|
||||||
void show_session_error(
|
|
||||||
const QString text, const QString info_text);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sig_load_file(QString);
|
void sig_load_file(QString);
|
||||||
@ -72,18 +65,14 @@ private slots:
|
|||||||
void on_actionCapture_triggered();
|
void on_actionCapture_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _enable;
|
|
||||||
SigSession* _session;
|
SigSession* _session;
|
||||||
|
|
||||||
QToolButton _file_button;
|
QToolButton _file_button;
|
||||||
|
QMenu *_menu;
|
||||||
QMenu *_menu;
|
QMenu *_menu_session; //when the hardware device is connected,it will be enable
|
||||||
|
|
||||||
QMenu *_menu_session; //when the hardware device is connected,it will be enable
|
|
||||||
QAction *_action_load;
|
QAction *_action_load;
|
||||||
QAction *_action_store;
|
QAction *_action_store;
|
||||||
QAction *_action_default;
|
QAction *_action_default;
|
||||||
|
|
||||||
QAction *_action_open;
|
QAction *_action_open;
|
||||||
QAction *_action_save;
|
QAction *_action_save;
|
||||||
QAction *_action_export;
|
QAction *_action_export;
|
||||||
|
@ -170,25 +170,6 @@ void LogoBar::dsl_connected(bool conn)
|
|||||||
_logo_button.setIcon(QIcon(iconPath+"/logo_noColor.svg"));
|
_logo_button.setIcon(QIcon(iconPath+"/logo_noColor.svg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoBar::session_error(
|
|
||||||
const QString text, const QString info_text)
|
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod(this, "show_session_error",
|
|
||||||
Qt::QueuedConnection, Q_ARG(QString, text),
|
|
||||||
Q_ARG(QString, info_text));
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogoBar::show_session_error(
|
|
||||||
const QString text, const QString info_text)
|
|
||||||
{
|
|
||||||
dialogs::DSMessageBox msg(this);
|
|
||||||
msg.mBox()->setText(text);
|
|
||||||
msg.mBox()->setInformativeText(info_text);
|
|
||||||
msg.mBox()->setStandardButtons(QMessageBox::Ok);
|
|
||||||
msg.mBox()->setIcon(QMessageBox::Warning);
|
|
||||||
msg.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogoBar::on_actionEn_triggered()
|
void LogoBar::on_actionEn_triggered()
|
||||||
{
|
{
|
||||||
_language->setIcon(QIcon::fromTheme("file",
|
_language->setIcon(QIcon::fromTheme("file",
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../interface/uicallback.h"
|
#include "../interface/icallbacks.h"
|
||||||
|
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
@ -59,11 +59,6 @@ private:
|
|||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void reStyle();
|
void reStyle();
|
||||||
|
|
||||||
void session_error(
|
|
||||||
const QString text, const QString info_text);
|
|
||||||
void show_session_error(
|
|
||||||
const QString text, const QString info_text);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//post event message to open user help document, MainWindow class receive it
|
//post event message to open user help document, MainWindow class receive it
|
||||||
void sig_open_doc();
|
void sig_open_doc();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -33,12 +33,16 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "../ui/dscombobox.h"
|
#include "../ui/dscombobox.h"
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
struct st_dev_inst;
|
struct st_dev_inst;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
struct ds_device_info;
|
||||||
|
|
||||||
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv
|
namespace pv
|
||||||
{
|
{
|
||||||
class SigSession;
|
class SigSession;
|
||||||
|
|
||||||
namespace device
|
namespace device
|
||||||
@ -69,47 +73,36 @@ namespace pv
|
|||||||
static const QString RLEString;
|
static const QString RLEString;
|
||||||
static const QString DIVString;
|
static const QString DIVString;
|
||||||
static const uint64_t ZeroTimeBase = SR_US(2);
|
static const uint64_t ZeroTimeBase = SR_US(2);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SamplingBar(SigSession *session, QWidget *parent);
|
SamplingBar(SigSession *session, QWidget *parent);
|
||||||
void set_device_list(const std::list<DevInst*> &devices, DevInst* selected);
|
|
||||||
DevInst *get_selected_device();
|
double hori_knob(int dir);
|
||||||
|
double get_hori_res();
|
||||||
|
void update_device_list();
|
||||||
|
void reload();
|
||||||
|
void update_view_status();
|
||||||
|
void config_device();
|
||||||
|
ds_device_handle get_next_device_handle();
|
||||||
void update_sample_rate_selector();
|
void update_sample_rate_selector();
|
||||||
|
|
||||||
void set_sampling(bool sampling);
|
|
||||||
bool get_sampling();
|
|
||||||
bool get_instant();
|
|
||||||
|
|
||||||
void enable_toggle(bool enable);
|
|
||||||
void enable_run_stop(bool enable);
|
|
||||||
void enable_instant(bool enable);
|
|
||||||
|
|
||||||
double hori_knob(int dir);
|
|
||||||
double commit_hori_res();
|
|
||||||
double get_hori_res();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void set_sample_rate(uint64_t sample_rate);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sig_run_stop();
|
void sig_store_session_data();
|
||||||
void sig_instant_stop();
|
|
||||||
void sig_device_selected();
|
|
||||||
void sig_device_updated();
|
|
||||||
void sig_duration_changed();
|
|
||||||
void sig_show_calibration();
|
|
||||||
void sig_hide_calibration();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void reStyle();
|
void reStyle();
|
||||||
|
void set_sample_rate(uint64_t sample_rate);
|
||||||
|
double commit_hori_res();
|
||||||
|
|
||||||
void update_sample_rate_selector_value();
|
void update_sample_rate_selector_value();
|
||||||
void update_sample_count_selector();
|
void update_sample_count_selector();
|
||||||
void update_sample_count_selector_value();
|
void update_sample_count_selector_value();
|
||||||
void commit_settings();
|
void commit_settings();
|
||||||
void setting_adj();
|
void setting_adj();
|
||||||
|
void enable_toggle(bool enable);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_mode();
|
void on_mode();
|
||||||
@ -118,43 +111,40 @@ namespace pv
|
|||||||
void on_device_selected();
|
void on_device_selected();
|
||||||
void on_samplerate_sel(int index);
|
void on_samplerate_sel(int index);
|
||||||
void on_samplecount_sel(int index);
|
void on_samplecount_sel(int index);
|
||||||
|
|
||||||
void show_session_error(
|
|
||||||
const QString text, const QString info_text);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void on_configure();
|
void on_configure();
|
||||||
void zero_adj();
|
void zero_adj();
|
||||||
void reload();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession *_session;
|
SigSession *_session;
|
||||||
mutable std::mutex _sampling_mutex;
|
|
||||||
bool _enable;
|
|
||||||
bool _sampling;
|
|
||||||
|
|
||||||
QToolButton _device_type;
|
DsComboBox _device_selector;
|
||||||
DsComboBox _device_selector;
|
DsComboBox _sample_count;
|
||||||
std::map<const void *, DevInst*> _device_selector_map;
|
DsComboBox _sample_rate;
|
||||||
bool _updating_device_selector;
|
|
||||||
|
|
||||||
QToolButton _configure_button;
|
|
||||||
DsComboBox _sample_count;
|
|
||||||
DsComboBox _sample_rate;
|
|
||||||
bool _updating_sample_rate;
|
bool _updating_sample_rate;
|
||||||
bool _updating_sample_count;
|
bool _updating_sample_count;
|
||||||
|
bool _updating_device_list;
|
||||||
|
|
||||||
|
QToolButton _device_type;
|
||||||
|
QToolButton _configure_button;
|
||||||
QToolButton _run_stop_button;
|
QToolButton _run_stop_button;
|
||||||
QToolButton _instant_button;
|
QToolButton _instant_button;
|
||||||
|
QToolButton _mode_button;
|
||||||
|
|
||||||
QAction *_run_stop_action;
|
QAction *_run_stop_action;
|
||||||
QAction *_instant_action;
|
QAction *_instant_action;
|
||||||
QAction *_mode_action;
|
QAction *_mode_action;
|
||||||
QToolButton _mode_button;
|
|
||||||
|
|
||||||
QMenu *_mode_menu;
|
QMenu *_mode_menu;
|
||||||
QAction *_action_repeat;
|
QAction *_action_repeat;
|
||||||
QAction *_action_single;
|
QAction *_action_single;
|
||||||
bool _instant;
|
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
|
ds_device_handle _last_device_handle;
|
||||||
|
ds_device_handle _next_switch_device;
|
||||||
|
int _last_device_index;
|
||||||
|
|
||||||
|
bool _is_run_as_instant;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace toolbars
|
} // namespace toolbars
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dialogs/fftoptions.h"
|
#include "../dialogs/fftoptions.h"
|
||||||
#include "../dialogs/lissajousoptions.h"
|
#include "../dialogs/lissajousoptions.h"
|
||||||
#include "../dialogs/mathoptions.h"
|
#include "../dialogs/mathoptions.h"
|
||||||
@ -241,21 +240,6 @@ void TrigBar::search_clicked()
|
|||||||
AppConfig::Instance().SaveFrame();
|
AppConfig::Instance().SaveFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrigBar::enable_toggle(bool enable)
|
|
||||||
{
|
|
||||||
_trig_button.setDisabled(!enable);
|
|
||||||
_protocol_button.setDisabled(!enable);
|
|
||||||
_measure_button.setDisabled(!enable);
|
|
||||||
_search_button.setDisabled(!enable);
|
|
||||||
_function_button.setDisabled(!enable);
|
|
||||||
_setting_button.setDisabled(!enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrigBar::enable_protocol(bool enable)
|
|
||||||
{
|
|
||||||
_protocol_button.setDisabled(!enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrigBar::close_all()
|
void TrigBar::close_all()
|
||||||
{
|
{
|
||||||
if (_trig_button.isChecked()) {
|
if (_trig_button.isChecked()) {
|
||||||
@ -280,7 +264,9 @@ void TrigBar::reload()
|
|||||||
{
|
{
|
||||||
close_all();
|
close_all();
|
||||||
|
|
||||||
if (_session->get_device()->dev_inst()->mode == LOGIC) {
|
int mode = _session->get_device()->get_work_mode();
|
||||||
|
|
||||||
|
if (mode == LOGIC) {
|
||||||
_trig_action->setVisible(true);
|
_trig_action->setVisible(true);
|
||||||
_protocol_action->setVisible(true);
|
_protocol_action->setVisible(true);
|
||||||
_measure_action->setVisible(true);
|
_measure_action->setVisible(true);
|
||||||
@ -289,7 +275,7 @@ void TrigBar::reload()
|
|||||||
_action_lissajous->setVisible(false);
|
_action_lissajous->setVisible(false);
|
||||||
_action_dispalyOptions->setVisible(true);
|
_action_dispalyOptions->setVisible(true);
|
||||||
|
|
||||||
} else if (_session->get_device()->dev_inst()->mode == ANALOG) {
|
} else if (mode == ANALOG) {
|
||||||
_trig_action->setVisible(false);
|
_trig_action->setVisible(false);
|
||||||
_protocol_action->setVisible(false);
|
_protocol_action->setVisible(false);
|
||||||
_measure_action->setVisible(true);
|
_measure_action->setVisible(true);
|
||||||
@ -298,7 +284,7 @@ void TrigBar::reload()
|
|||||||
_action_lissajous->setVisible(false);
|
_action_lissajous->setVisible(false);
|
||||||
_action_dispalyOptions->setVisible(false);
|
_action_dispalyOptions->setVisible(false);
|
||||||
|
|
||||||
} else if (_session->get_device()->dev_inst()->mode == DSO) {
|
} else if (mode == DSO) {
|
||||||
_trig_action->setVisible(true);
|
_trig_action->setVisible(true);
|
||||||
_protocol_action->setVisible(false);
|
_protocol_action->setVisible(false);
|
||||||
_measure_action->setVisible(true);
|
_measure_action->setVisible(true);
|
||||||
@ -308,8 +294,8 @@ void TrigBar::reload()
|
|||||||
_action_dispalyOptions->setVisible(false);
|
_action_dispalyOptions->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_toggle(true);
|
update_view_status();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrigBar::on_actionFft_triggered()
|
void TrigBar::on_actionFft_triggered()
|
||||||
@ -355,7 +341,6 @@ void TrigBar::on_actionLissajous_triggered()
|
|||||||
void TrigBar::restore_status()
|
void TrigBar::restore_status()
|
||||||
{
|
{
|
||||||
DockOptions *opt = getDockOptions();
|
DockOptions *opt = getDockOptions();
|
||||||
int mode = _session->get_device()->dev_inst()->mode;
|
|
||||||
|
|
||||||
if (opt->decodeDoc){
|
if (opt->decodeDoc){
|
||||||
_protocol_button.setChecked(true);
|
_protocol_button.setChecked(true);
|
||||||
@ -381,9 +366,9 @@ void TrigBar::restore_status()
|
|||||||
DockOptions* TrigBar::getDockOptions()
|
DockOptions* TrigBar::getDockOptions()
|
||||||
{
|
{
|
||||||
AppConfig &app = AppConfig::Instance();
|
AppConfig &app = AppConfig::Instance();
|
||||||
int mode = _session->get_device()->dev_inst()->mode;
|
int mode = _session->get_device()->get_work_mode();
|
||||||
|
|
||||||
if (mode == LOGIC)
|
if (mode == LOGIC)
|
||||||
return &app._frameOptions._logicDock;
|
return &app._frameOptions._logicDock;
|
||||||
else if (mode == DSO)
|
else if (mode == DSO)
|
||||||
return &app._frameOptions._dsoDock;
|
return &app._frameOptions._dsoDock;
|
||||||
@ -391,5 +376,17 @@ void TrigBar::restore_status()
|
|||||||
return &app._frameOptions._analogDock;
|
return &app._frameOptions._analogDock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrigBar::update_view_status()
|
||||||
|
{
|
||||||
|
bool bEnable = _session->is_working() == false;
|
||||||
|
|
||||||
|
_trig_button.setEnabled(bEnable);
|
||||||
|
_protocol_button.setEnabled(bEnable);
|
||||||
|
_measure_button.setEnabled(bEnable);
|
||||||
|
_search_button.setEnabled(bEnable);
|
||||||
|
_function_button.setEnabled(bEnable);
|
||||||
|
_setting_button.setEnabled(bEnable);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace toolbars
|
} // namespace toolbars
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
class DockOptions;
|
class DockOptions;
|
||||||
|
|
||||||
@ -45,16 +46,15 @@ class TrigBar : public QToolBar
|
|||||||
public:
|
public:
|
||||||
explicit TrigBar(SigSession *session, QWidget *parent = 0);
|
explicit TrigBar(SigSession *session, QWidget *parent = 0);
|
||||||
|
|
||||||
void enable_toggle(bool enable);
|
|
||||||
void enable_protocol(bool enable);
|
|
||||||
void close_all();
|
void close_all();
|
||||||
void reload();
|
void reload();
|
||||||
|
void update_view_status();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void reStyle();
|
void reStyle();
|
||||||
DockOptions* getDockOptions();
|
DockOptions* getDockOptions();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sig_setTheme(QString style);
|
void sig_setTheme(QString style);
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "../data/analog.h"
|
#include "../data/analog.h"
|
||||||
#include "../data/analogsnapshot.h"
|
#include "../data/analogsnapshot.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
|
||||||
@ -45,9 +44,8 @@ const QColor AnalogSignal::SignalColours[4] = {
|
|||||||
|
|
||||||
const float AnalogSignal::EnvelopeThreshold = 16.0f;
|
const float AnalogSignal::EnvelopeThreshold = 16.0f;
|
||||||
|
|
||||||
AnalogSignal::AnalogSignal(DevInst *dev_inst,data::Analog *data,
|
AnalogSignal::AnalogSignal(data::Analog *data, sr_channel *probe) :
|
||||||
sr_channel *probe) :
|
Signal(probe),
|
||||||
Signal(dev_inst, probe),
|
|
||||||
_data(data),
|
_data(data),
|
||||||
_rects(NULL),
|
_rects(NULL),
|
||||||
_hover_en(false),
|
_hover_en(false),
|
||||||
@ -60,7 +58,7 @@ AnalogSignal::AnalogSignal(DevInst *dev_inst,data::Analog *data,
|
|||||||
|
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
// channel bits
|
// channel bits
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_bits = g_variant_get_byte(gvar);
|
_bits = g_variant_get_byte(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -70,14 +68,14 @@ AnalogSignal::AnalogSignal(DevInst *dev_inst,data::Analog *data,
|
|||||||
dsv_warn("%s%d", "Warning: config_get SR_CONF_UNIT_BITS failed, set to %d(default).", DefaultBits);
|
dsv_warn("%s%d", "Warning: config_get SR_CONF_UNIT_BITS failed, set to %d(default).", DefaultBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_ref_min = g_variant_get_uint32(gvar);
|
_ref_min = g_variant_get_uint32(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
} else {
|
} else {
|
||||||
_ref_min = 1;
|
_ref_min = 1;
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_ref_max = g_variant_get_uint32(gvar);
|
_ref_max = g_variant_get_uint32(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -86,7 +84,7 @@ AnalogSignal::AnalogSignal(DevInst *dev_inst,data::Analog *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- vpos
|
// -- vpos
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_zero_offset = g_variant_get_uint16(gvar);
|
_zero_offset = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -155,7 +153,7 @@ double AnalogSignal::get_ref_max()
|
|||||||
int AnalogSignal::get_hw_offset()
|
int AnalogSignal::get_hw_offset()
|
||||||
{
|
{
|
||||||
int hw_offset = 0;
|
int hw_offset = 0;
|
||||||
GVariant *gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET);
|
GVariant *gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
hw_offset = g_variant_get_uint16(gvar);
|
hw_offset = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -168,23 +166,23 @@ int AnalogSignal::commit_settings()
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// -- enable
|
// -- enable
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
||||||
g_variant_new_boolean(enabled()));
|
g_variant_new_boolean(enabled()));
|
||||||
|
|
||||||
// -- vdiv
|
// -- vdiv
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
||||||
g_variant_new_uint64(_probe->vdiv));
|
g_variant_new_uint64(_probe->vdiv));
|
||||||
|
|
||||||
// -- coupling
|
// -- coupling
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
||||||
g_variant_new_byte(_probe->coupling));
|
g_variant_new_byte(_probe->coupling));
|
||||||
|
|
||||||
// -- offset
|
// -- offset
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_probe->offset));
|
g_variant_new_uint16(_probe->offset));
|
||||||
|
|
||||||
// -- trig_value
|
// -- trig_value
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
||||||
g_variant_new_byte(_probe->trig_value));
|
g_variant_new_byte(_probe->trig_value));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -196,7 +194,7 @@ bool AnalogSignal::measure(const QPointF &p)
|
|||||||
if (!enabled())
|
if (!enabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_view->session().get_capture_state() != SigSession::Stopped)
|
if (_view->session().is_stopped_status() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QRectF window = get_view_rect();
|
const QRectF window = get_view_rect();
|
||||||
@ -285,7 +283,7 @@ QPointF AnalogSignal::get_point(uint64_t index, float &value)
|
|||||||
uint64_t AnalogSignal::get_vdiv()
|
uint64_t AnalogSignal::get_vdiv()
|
||||||
{
|
{
|
||||||
uint64_t vdiv = 0;
|
uint64_t vdiv = 0;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_VDIV);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_VDIV);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vdiv = g_variant_get_uint64(gvar);
|
vdiv = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -296,7 +294,7 @@ uint64_t AnalogSignal::get_vdiv()
|
|||||||
uint8_t AnalogSignal::get_acCoupling()
|
uint8_t AnalogSignal::get_acCoupling()
|
||||||
{
|
{
|
||||||
uint64_t coupling = 0;
|
uint64_t coupling = 0;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
coupling = g_variant_get_byte(gvar);
|
coupling = g_variant_get_byte(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -307,7 +305,7 @@ uint8_t AnalogSignal::get_acCoupling()
|
|||||||
bool AnalogSignal::get_mapDefault()
|
bool AnalogSignal::get_mapDefault()
|
||||||
{
|
{
|
||||||
bool isDefault = true;
|
bool isDefault = true;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_DEFAULT);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_DEFAULT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
isDefault = g_variant_get_boolean(gvar);
|
isDefault = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -318,7 +316,7 @@ bool AnalogSignal::get_mapDefault()
|
|||||||
QString AnalogSignal::get_mapUnit()
|
QString AnalogSignal::get_mapUnit()
|
||||||
{
|
{
|
||||||
QString unit;
|
QString unit;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_UNIT);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_UNIT);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
unit = g_variant_get_string(gvar, NULL);
|
unit = g_variant_get_string(gvar, NULL);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -329,7 +327,7 @@ QString AnalogSignal::get_mapUnit()
|
|||||||
double AnalogSignal::get_mapMin()
|
double AnalogSignal::get_mapMin()
|
||||||
{
|
{
|
||||||
double min = -1;
|
double min = -1;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MIN);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
min = g_variant_get_double(gvar);
|
min = g_variant_get_double(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -340,7 +338,7 @@ double AnalogSignal::get_mapMin()
|
|||||||
double AnalogSignal::get_mapMax()
|
double AnalogSignal::get_mapMax()
|
||||||
{
|
{
|
||||||
double max = 1;
|
double max = 1;
|
||||||
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MAX);
|
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MAX);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
max = g_variant_get_double(gvar);
|
max = g_variant_get_double(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -352,7 +350,7 @@ uint64_t AnalogSignal::get_factor()
|
|||||||
{
|
{
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
uint64_t factor;
|
uint64_t factor;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
factor = g_variant_get_uint64(gvar);
|
factor = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -405,11 +403,11 @@ int AnalogSignal::get_zero_vpos()
|
|||||||
|
|
||||||
void AnalogSignal::set_zero_ratio(double ratio)
|
void AnalogSignal::set_zero_ratio(double ratio)
|
||||||
{
|
{
|
||||||
if (_view->session().get_capture_state() == SigSession::Running)
|
if (_view->session().is_running_status())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_zero_offset = ratio2value(ratio);
|
_zero_offset = ratio2value(ratio);
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_zero_offset));
|
g_variant_new_uint16(_zero_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,7 +556,7 @@ void AnalogSignal::paint_fore(QPainter &p, int left, int right, QColor fore, QCo
|
|||||||
fore.setAlpha(View::ForeAlpha);
|
fore.setAlpha(View::ForeAlpha);
|
||||||
if(enabled()) {
|
if(enabled()) {
|
||||||
// Paint measure
|
// Paint measure
|
||||||
if (_view->session().get_capture_state() == SigSession::Stopped)
|
if (_view->session().is_stopped_status())
|
||||||
paint_hover_measure(p, fore, back);
|
paint_hover_measure(p, fore, back);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
static const uint8_t DefaultBits = 8;
|
static const uint8_t DefaultBits = 8;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnalogSignal(DevInst* dev_inst, pv::data::Analog *data,
|
AnalogSignal(pv::data::Analog *data,
|
||||||
sr_channel *probe);
|
sr_channel *probe);
|
||||||
|
|
||||||
AnalogSignal(view::AnalogSignal* s, pv::data::Analog *data, sr_channel *probe);
|
AnalogSignal(view::AnalogSignal* s, pv::data::Analog *data, sr_channel *probe);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "ruler.h"
|
#include "ruler.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "../device/device.h"
|
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libsigrokdecode.h"
|
#include <libsigrokdecode.h>
|
||||||
|
#include "../dsvdef.h"
|
||||||
#include "../dsvdef.h"
|
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
@ -47,7 +45,6 @@
|
|||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
#include "../widgets/decodergroupbox.h"
|
#include "../widgets/decodergroupbox.h"
|
||||||
#include "../widgets/decodermenu.h"
|
#include "../widgets/decodermenu.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../view/cursor.h"
|
#include "../view/cursor.h"
|
||||||
#include "../toolbars/titlebar.h"
|
#include "../toolbars/titlebar.h"
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
@ -569,7 +566,7 @@ void DecodeTrace::on_new_decode_data()
|
|||||||
}
|
}
|
||||||
decoded_progress(_progress);
|
decoded_progress(_progress);
|
||||||
|
|
||||||
if (_view && _view->session().get_capture_state() == SigSession::Stopped)
|
if (_view && _view->session().is_stopped_status())
|
||||||
_view->data_updated();
|
_view->data_updated();
|
||||||
if (_totalHeight/_view->get_signalHeight() != rows_size())
|
if (_totalHeight/_view->get_signalHeight() != rows_size())
|
||||||
_view->signals_changed();
|
_view->signals_changed();
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
#include "devmode.h"
|
#include "devmode.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../device/file.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
@ -35,17 +33,28 @@
|
|||||||
|
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
#include "../ui/msgbox.h"
|
#include "../ui/msgbox.h"
|
||||||
|
#include "../log.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const struct dev_mode_name dev_mode_name_list[] =
|
||||||
|
{
|
||||||
|
{LOGIC, "Logic Analyzer", "逻辑分析仪", "la.svg"},
|
||||||
|
{ANALOG, "Data Acquisition", "数据记录仪", "daq.svg"},
|
||||||
|
{DSO, "Oscilloscope", "示波器", "osc.svg"},
|
||||||
|
};
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace view {
|
namespace view {
|
||||||
|
|
||||||
DevMode::DevMode(QWidget *parent, SigSession *session) :
|
DevMode::DevMode(QWidget *parent, SigSession *session) :
|
||||||
QWidget(parent),
|
QWidget(parent)
|
||||||
_session(session)
|
|
||||||
{
|
{
|
||||||
_bFile = false;
|
_bFile = false;
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
_session = session;
|
||||||
|
_device_agent = session->get_device();
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->setContentsMargins(2, 0, 0, 0);
|
layout->setContentsMargins(2, 0, 0, 0);
|
||||||
|
|
||||||
@ -93,8 +102,10 @@ void DevMode::changeEvent(QEvent *event)
|
|||||||
|
|
||||||
void DevMode::set_device()
|
void DevMode::set_device()
|
||||||
{
|
{
|
||||||
DevInst* dev_inst = _session->get_device();
|
if (_device_agent->have_instance() == false){
|
||||||
assert(dev_inst);
|
dsv_detail("%s", "DevMode::set_device, Have no device.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_bFile = false;
|
_bFile = false;
|
||||||
|
|
||||||
@ -115,35 +126,37 @@ void DevMode::set_device()
|
|||||||
|
|
||||||
QString iconPath = GetIconPath() + "/";
|
QString iconPath = GetIconPath() + "/";
|
||||||
|
|
||||||
for (const GSList *l = dev_inst->get_dev_mode_list(); l; l = l->next)
|
auto dev_mode_list = _device_agent->get_device_mode_list();
|
||||||
|
|
||||||
|
for (const GSList *l = dev_mode_list; l; l = l->next)
|
||||||
{
|
{
|
||||||
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
|
||||||
QString icon_name = QString::fromLocal8Bit(mode->icon);
|
auto *mode_name = get_mode_name(mode->mode);
|
||||||
|
QString icon_name = QString::fromLocal8Bit(mode_name->_logo);
|
||||||
|
|
||||||
QAction *action = new QAction(this);
|
QAction *action = new QAction(this);
|
||||||
action->setIcon(QIcon(iconPath + "square-" + icon_name));
|
action->setIcon(QIcon(iconPath + "square-" + icon_name));
|
||||||
if (lan == LAN_CN)
|
if (lan == LAN_CN)
|
||||||
action->setText(mode->name_cn);
|
action->setText(mode_name->_name_cn);
|
||||||
else
|
else
|
||||||
action->setText(mode->name);
|
action->setText(mode_name->_name_en);
|
||||||
|
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(on_mode_change()));
|
connect(action, SIGNAL(triggered()), this, SLOT(on_mode_change()));
|
||||||
|
|
||||||
_mode_list[action] = mode;
|
_mode_list[action] = mode;
|
||||||
if (dev_inst->dev_inst()->mode == _mode_list[action]->mode)
|
if (_device_agent->get_work_mode() == _mode_list[action]->mode)
|
||||||
{
|
{
|
||||||
QString icon_fname = iconPath + icon_name;
|
QString icon_fname = iconPath + icon_name;
|
||||||
_mode_btn->setIcon(QIcon(icon_fname));
|
_mode_btn->setIcon(QIcon(icon_fname));
|
||||||
if (lan == LAN_CN)
|
if (lan == LAN_CN)
|
||||||
_mode_btn->setText(mode->name_cn);
|
_mode_btn->setText(mode_name->_name_cn);
|
||||||
else
|
else
|
||||||
_mode_btn->setText(mode->name);
|
_mode_btn->setText(mode_name->_name_en);
|
||||||
}
|
}
|
||||||
_pop_menu->addAction(action);
|
_pop_menu->addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dynamic_cast<File *>(dev_inst)))
|
if (_device_agent->is_file()){
|
||||||
{
|
|
||||||
_close_button->setDisabled(false);
|
_close_button->setDisabled(false);
|
||||||
_close_button->setIcon(QIcon(iconPath + "/close.svg"));
|
_close_button->setIcon(QIcon(iconPath + "/close.svg"));
|
||||||
_bFile = true;
|
_bFile = true;
|
||||||
@ -164,11 +177,15 @@ void DevMode::paintEvent(QPaintEvent*)
|
|||||||
|
|
||||||
void DevMode::on_mode_change()
|
void DevMode::on_mode_change()
|
||||||
{
|
{
|
||||||
DevInst* dev_inst = _session->get_device();
|
if (_device_agent->have_instance() == false){
|
||||||
assert(dev_inst);
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
if (dev_inst->dev_inst()->mode == _mode_list[action]->mode)
|
|
||||||
|
if (_device_agent->get_work_mode() == _mode_list[action]->mode){
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString iconPath = GetIconPath();
|
QString iconPath = GetIconPath();
|
||||||
AppConfig &app = AppConfig::Instance();
|
AppConfig &app = AppConfig::Instance();
|
||||||
@ -176,40 +193,41 @@ void DevMode::on_mode_change()
|
|||||||
|
|
||||||
for(auto i = _mode_list.begin();i != _mode_list.end(); i++)
|
for(auto i = _mode_list.begin();i != _mode_list.end(); i++)
|
||||||
{
|
{
|
||||||
if ((*i).first == action) {
|
if ((*i).first == action){
|
||||||
if (dev_inst->dev_inst()->mode != (*i).second->mode) {
|
|
||||||
_session->set_run_mode(SigSession::Single);
|
|
||||||
_session->set_repeating(false);
|
|
||||||
_session->stop_capture();
|
|
||||||
_session->capture_state_changed(SigSession::Stopped);
|
|
||||||
_session->session_save();
|
|
||||||
dev_inst->set_config(NULL, NULL,
|
|
||||||
SR_CONF_DEVICE_MODE,
|
|
||||||
g_variant_new_int16((*i).second->mode));
|
|
||||||
|
|
||||||
QString icon_fname = iconPath + "/" + QString::fromLocal8Bit((*i).second->icon);
|
int mode = (*i).second->mode;
|
||||||
|
if (_device_agent->get_work_mode() == mode){
|
||||||
_mode_btn->setIcon(QIcon(icon_fname));
|
dsv_info("%s", "Current mode is set.");
|
||||||
if (lan == LAN_CN)
|
break;
|
||||||
_mode_btn->setText((*i).second->name_cn);
|
|
||||||
else
|
|
||||||
_mode_btn->setText((*i).second->name);
|
|
||||||
dev_changed(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_session->stop_capture();
|
||||||
|
_session->set_repeat_mode(false);
|
||||||
|
_session->session_save();
|
||||||
|
_session->switch_work_mode(mode);
|
||||||
|
|
||||||
break;
|
auto *mode_name = get_mode_name(mode);
|
||||||
}
|
QString icon_fname = iconPath + "/" + QString::fromLocal8Bit(mode_name->_logo);
|
||||||
|
|
||||||
|
_mode_btn->setIcon(QIcon(icon_fname));
|
||||||
|
if (lan == LAN_CN)
|
||||||
|
_mode_btn->setText(mode_name->_name_cn);
|
||||||
|
else
|
||||||
|
_mode_btn->setText(mode_name->_name_en);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevMode::on_close()
|
void DevMode::on_close()
|
||||||
{
|
{
|
||||||
DevInst *dev_inst = _session->get_device();
|
if (_device_agent->have_instance() == false){
|
||||||
assert(dev_inst);
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (_bFile && MsgBox::Confirm(tr("are you sure to close the device?"))){
|
if (_bFile && MsgBox::Confirm(tr("Are you sure to close the device?"))){
|
||||||
_session->close_file(dev_inst);
|
_session->close_file(_device_agent->handle());
|
||||||
dev_changed(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,5 +256,14 @@ void DevMode::leaveEvent(QEvent*)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct dev_mode_name* DevMode::get_mode_name(int mode)
|
||||||
|
{
|
||||||
|
for(auto &o : dev_mode_name_list)
|
||||||
|
if (mode == o._mode){
|
||||||
|
return &o;
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
@ -34,8 +34,17 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include "libsigrok.h"
|
#include <libsigrok.h>
|
||||||
|
|
||||||
|
struct dev_mode_name{
|
||||||
|
int _mode;
|
||||||
|
const char *_name_en;
|
||||||
|
const char *_name_cn;
|
||||||
|
const char *_logo;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DeviceAgent;
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
|
|
||||||
namespace device{
|
namespace device{
|
||||||
@ -65,8 +74,8 @@ private:
|
|||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void leaveEvent(QEvent *event);
|
void leaveEvent(QEvent *event);
|
||||||
|
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
|
const dev_mode_name* get_mode_name(int mode);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void set_device();
|
void set_device();
|
||||||
@ -75,8 +84,7 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
signals:
|
|
||||||
void dev_changed(bool close);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SigSession *_session;
|
SigSession *_session;
|
||||||
@ -86,6 +94,8 @@ private:
|
|||||||
QPoint _mouse_point;
|
QPoint _mouse_point;
|
||||||
QToolButton *_close_button;
|
QToolButton *_close_button;
|
||||||
bool _bFile;
|
bool _bFile;
|
||||||
|
|
||||||
|
DeviceAgent *_device_agent;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
#include "../data/dso.h"
|
#include "../data/dso.h"
|
||||||
#include "../data/dsosnapshot.h"
|
#include "../data/dsosnapshot.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -53,10 +53,9 @@ const QColor DsoSignal::SignalColours[4] = {
|
|||||||
|
|
||||||
const float DsoSignal::EnvelopeThreshold = 256.0f;
|
const float DsoSignal::EnvelopeThreshold = 256.0f;
|
||||||
|
|
||||||
DsoSignal::DsoSignal(DevInst *dev_inst,
|
DsoSignal::DsoSignal(data::Dso *data,
|
||||||
data::Dso *data,
|
|
||||||
sr_channel *probe):
|
sr_channel *probe):
|
||||||
Signal(dev_inst, probe),
|
Signal(probe),
|
||||||
_data(data),
|
_data(data),
|
||||||
_scale(0),
|
_scale(0),
|
||||||
_en_lock(false),
|
_en_lock(false),
|
||||||
@ -75,12 +74,17 @@ DsoSignal::DsoSignal(DevInst *dev_inst,
|
|||||||
{
|
{
|
||||||
QVector<uint64_t> vValue;
|
QVector<uint64_t> vValue;
|
||||||
QVector<QString> vUnit;
|
QVector<QString> vUnit;
|
||||||
for(uint64_t i = 0; i < vDialUnitCount; i++)
|
|
||||||
|
for(uint64_t i = 0; i < vDialUnitCount; i++){
|
||||||
vUnit.append(vDialUnit[i]);
|
vUnit.append(vDialUnit[i]);
|
||||||
|
}
|
||||||
|
|
||||||
GVariant *gvar_list, *gvar_list_vdivs;
|
GVariant *gvar_list, *gvar_list_vdivs;
|
||||||
if (sr_config_list(dev_inst->dev_inst()->driver, dev_inst->dev_inst(),
|
|
||||||
NULL, SR_CONF_PROBE_VDIV, &gvar_list) == SR_OK) {
|
gvar_list = session->get_device()->get_config_list(NULL, SR_CONF_PROBE_VDIV);
|
||||||
|
|
||||||
|
if (gvar_list != NULL)
|
||||||
|
{
|
||||||
assert(gvar_list);
|
assert(gvar_list);
|
||||||
if ((gvar_list_vdivs = g_variant_lookup_value(gvar_list,
|
if ((gvar_list_vdivs = g_variant_lookup_value(gvar_list,
|
||||||
"vdivs", G_VARIANT_TYPE("at")))) {
|
"vdivs", G_VARIANT_TYPE("at")))) {
|
||||||
@ -117,7 +121,7 @@ pv::data::Dso* DsoSignal::dso_data()
|
|||||||
|
|
||||||
void DsoSignal::set_scale(int height)
|
void DsoSignal::set_scale(int height)
|
||||||
{
|
{
|
||||||
_scale = height / (_ref_max - _ref_min) * _view->session().stop_scale();
|
_scale = height / (_ref_max - _ref_min) * session->stop_scale();
|
||||||
}
|
}
|
||||||
|
|
||||||
float DsoSignal::get_scale()
|
float DsoSignal::get_scale()
|
||||||
@ -146,15 +150,15 @@ int DsoSignal::get_name_width()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DsoSignal::set_enable(bool enable)
|
void DsoSignal::set_enable(bool enable)
|
||||||
{
|
{
|
||||||
if (_dev_inst->name() == "DSLogic" &&
|
if (session->get_device()->name() == "DSLogic" && get_index() == 0){
|
||||||
get_index() == 0)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_en_lock = true;
|
_en_lock = true;
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
bool cur_enable;
|
bool cur_enable;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_EN);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_EN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
cur_enable = g_variant_get_boolean(gvar);
|
cur_enable = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -170,20 +174,24 @@ void DsoSignal::set_enable(bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool running = false;
|
bool running = false;
|
||||||
if (_view->session().get_capture_state() == SigSession::Running) {
|
|
||||||
|
if (session->is_running_status()) {
|
||||||
running = true;
|
running = true;
|
||||||
_view->session().stop_capture();
|
session->stop_capture();
|
||||||
}
|
}
|
||||||
while(_view->session().get_capture_state() == SigSession::Running)
|
|
||||||
|
while(session->is_running_status())
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
set_vDialActive(false);
|
set_vDialActive(false);
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
||||||
g_variant_new_boolean(enable));
|
g_variant_new_boolean(enable));
|
||||||
|
|
||||||
_view->update_hori_res();
|
_view->update_hori_res();
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
_view->session().repeat_resume();
|
session->stop_capture();
|
||||||
|
session->start_capture(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_view->set_update(_viewport, true);
|
_view->set_update(_viewport, true);
|
||||||
@ -203,29 +211,34 @@ void DsoSignal::set_vDialActive(bool active)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DsoSignal::go_vDialPre(bool manul)
|
bool DsoSignal::go_vDialPre(bool manul)
|
||||||
{
|
{
|
||||||
if (_autoV && manul)
|
if (_autoV && manul)
|
||||||
autoV_end();
|
autoV_end();
|
||||||
|
|
||||||
|
if (enabled() && !_vDial->isMin())
|
||||||
|
{
|
||||||
|
if (session->is_running_status())
|
||||||
|
session->refresh(RefreshShort);
|
||||||
|
|
||||||
if (enabled() && !_vDial->isMin()) {
|
|
||||||
if (_view->session().get_capture_state() == SigSession::Running)
|
|
||||||
_view->session().refresh(RefreshShort);
|
|
||||||
const double pre_vdiv = _vDial->get_value();
|
const double pre_vdiv = _vDial->get_value();
|
||||||
_vDial->set_sel(_vDial->get_sel() - 1);
|
_vDial->set_sel(_vDial->get_sel() - 1);
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
|
||||||
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
||||||
g_variant_new_uint64(_vDial->get_value()));
|
g_variant_new_uint64(_vDial->get_value()));
|
||||||
if (_view->session().get_capture_state() == SigSession::Stopped) {
|
|
||||||
_view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value()));
|
if (session->is_stopped_status()) {
|
||||||
|
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value()));
|
||||||
set_scale(get_view_rect().height());
|
set_scale(get_view_rect().height());
|
||||||
}
|
}
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_zero_offset));
|
g_variant_new_uint16(_zero_offset));
|
||||||
|
|
||||||
_view->vDial_updated();
|
_view->vDial_updated();
|
||||||
_view->set_update(_viewport, true);
|
_view->set_update(_viewport, true);
|
||||||
_view->update();
|
_view->update();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (_autoV && !_autoV_over)
|
if (_autoV && !_autoV_over)
|
||||||
autoV_end();
|
autoV_end();
|
||||||
return false;
|
return false;
|
||||||
@ -235,27 +248,32 @@ bool DsoSignal::go_vDialPre(bool manul)
|
|||||||
bool DsoSignal::go_vDialNext(bool manul)
|
bool DsoSignal::go_vDialNext(bool manul)
|
||||||
{
|
{
|
||||||
if (_autoV && manul)
|
if (_autoV && manul)
|
||||||
autoV_end();
|
autoV_end();
|
||||||
|
|
||||||
|
if (enabled() && !_vDial->isMax())
|
||||||
|
{
|
||||||
|
if (session->is_running_status())
|
||||||
|
session->refresh(RefreshShort);
|
||||||
|
|
||||||
if (enabled() && !_vDial->isMax()) {
|
|
||||||
if (_view->session().get_capture_state() == SigSession::Running)
|
|
||||||
_view->session().refresh(RefreshShort);
|
|
||||||
const double pre_vdiv = _vDial->get_value();
|
const double pre_vdiv = _vDial->get_value();
|
||||||
_vDial->set_sel(_vDial->get_sel() + 1);
|
_vDial->set_sel(_vDial->get_sel() + 1);
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
|
||||||
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
||||||
g_variant_new_uint64(_vDial->get_value()));
|
g_variant_new_uint64(_vDial->get_value()));
|
||||||
if (_view->session().get_capture_state() == SigSession::Stopped) {
|
|
||||||
_view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value()));
|
if (session->is_stopped_status()) {
|
||||||
|
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value()));
|
||||||
set_scale(get_view_rect().height());
|
set_scale(get_view_rect().height());
|
||||||
}
|
}
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_zero_offset));
|
g_variant_new_uint16(_zero_offset));
|
||||||
|
|
||||||
_view->vDial_updated();
|
_view->vDial_updated();
|
||||||
_view->set_update(_viewport, true);
|
_view->set_update(_viewport, true);
|
||||||
_view->update();
|
_view->update();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (_autoV && !_autoV_over)
|
if (_autoV && !_autoV_over)
|
||||||
autoV_end();
|
autoV_end();
|
||||||
return false;
|
return false;
|
||||||
@ -264,10 +282,10 @@ bool DsoSignal::go_vDialNext(bool manul)
|
|||||||
|
|
||||||
bool DsoSignal::load_settings()
|
bool DsoSignal::load_settings()
|
||||||
{
|
{
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
|
|
||||||
// dso channel bits
|
// dso channel bits
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_bits = g_variant_get_byte(gvar);
|
_bits = g_variant_get_byte(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -276,17 +294,17 @@ bool DsoSignal::load_settings()
|
|||||||
_bits = DefaultBits;
|
_bits = DefaultBits;
|
||||||
dsv_warn("%s%d", "Warning: config_get SR_CONF_UNIT_BITS failed, set to %d(default).", DefaultBits);
|
dsv_warn("%s%d", "Warning: config_get SR_CONF_UNIT_BITS failed, set to %d(default).", DefaultBits);
|
||||||
|
|
||||||
if (strncmp(_dev_inst->name().toUtf8().data(), "virtual", 7))
|
if (strncmp(session->get_device()->name().toUtf8().data(), "virtual", 7))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_ref_min = g_variant_get_uint32(gvar);
|
_ref_min = g_variant_get_uint32(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
} else {
|
} else {
|
||||||
_ref_min = 1;
|
_ref_min = 1;
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_ref_max = g_variant_get_uint32(gvar);
|
_ref_max = g_variant_get_uint32(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -297,7 +315,7 @@ bool DsoSignal::load_settings()
|
|||||||
// -- vdiv
|
// -- vdiv
|
||||||
uint64_t vdiv;
|
uint64_t vdiv;
|
||||||
uint64_t vfactor;
|
uint64_t vfactor;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_VDIV);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_VDIV);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vdiv = g_variant_get_uint64(gvar);
|
vdiv = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -306,7 +324,7 @@ bool DsoSignal::load_settings()
|
|||||||
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_VDIV failed.");
|
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_VDIV failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
vfactor = g_variant_get_uint64(gvar);
|
vfactor = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -320,7 +338,7 @@ bool DsoSignal::load_settings()
|
|||||||
_vDial->set_factor(vfactor);
|
_vDial->set_factor(vfactor);
|
||||||
|
|
||||||
// -- coupling
|
// -- coupling
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_acCoupling = g_variant_get_byte(gvar);
|
_acCoupling = g_variant_get_byte(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -331,7 +349,7 @@ bool DsoSignal::load_settings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- vpos
|
// -- vpos
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_zero_offset = g_variant_get_uint16(gvar);
|
_zero_offset = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -342,7 +360,7 @@ bool DsoSignal::load_settings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- trig_value
|
// -- trig_value
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_TRIGGER_VALUE);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_TRIGGER_VALUE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
_trig_value = g_variant_get_byte(gvar);
|
_trig_value = g_variant_get_byte(gvar);
|
||||||
_trig_delta = get_trig_vrate() - get_zero_ratio();
|
_trig_delta = get_trig_vrate() - get_zero_ratio();
|
||||||
@ -350,7 +368,7 @@ bool DsoSignal::load_settings()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dsv_err("%s", "ERROR: config_get SR_CONF_TRIGGER_VALUE failed.");
|
dsv_err("%s", "ERROR: config_get SR_CONF_TRIGGER_VALUE failed.");
|
||||||
if (strncmp(_dev_inst->name().toUtf8().data(), "virtual", 7))
|
if (strncmp(session->get_device()->name().toUtf8().data(), "virtual", 7))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,26 +382,27 @@ bool DsoSignal::load_settings()
|
|||||||
int DsoSignal::commit_settings()
|
int DsoSignal::commit_settings()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// -- enable
|
// -- enable
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN,
|
||||||
g_variant_new_boolean(enabled()));
|
g_variant_new_boolean(enabled()));
|
||||||
|
|
||||||
// -- vdiv
|
// -- vdiv
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
|
||||||
g_variant_new_uint64(_vDial->get_value()));
|
g_variant_new_uint64(_vDial->get_value()));
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR,
|
||||||
g_variant_new_uint64(_vDial->get_factor()));
|
g_variant_new_uint64(_vDial->get_factor()));
|
||||||
|
|
||||||
// -- coupling
|
// -- coupling
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
||||||
g_variant_new_byte(_acCoupling));
|
g_variant_new_byte(_acCoupling));
|
||||||
|
|
||||||
// -- offset
|
// -- offset
|
||||||
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_zero_offset));
|
g_variant_new_uint16(_zero_offset));
|
||||||
|
|
||||||
// -- trig_value
|
// -- trig_value
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
||||||
g_variant_new_byte(_trig_value));
|
g_variant_new_byte(_trig_value));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -412,8 +431,8 @@ uint8_t DsoSignal::get_acCoupling()
|
|||||||
void DsoSignal::set_acCoupling(uint8_t coupling)
|
void DsoSignal::set_acCoupling(uint8_t coupling)
|
||||||
{
|
{
|
||||||
if (enabled()) {
|
if (enabled()) {
|
||||||
_acCoupling = coupling;
|
_acCoupling = coupling;
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING,
|
||||||
g_variant_new_byte(_acCoupling));
|
g_variant_new_byte(_acCoupling));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,8 +458,8 @@ double DsoSignal::pos2ratio(int pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double DsoSignal::get_trig_vrate()
|
double DsoSignal::get_trig_vrate()
|
||||||
{
|
{
|
||||||
if (_dev_inst->name() == "DSLogic")
|
if (session->get_device()->name() == "DSLogic")
|
||||||
return value2ratio(_trig_value - ratio2value(0.5)) + get_zero_ratio();
|
return value2ratio(_trig_value - ratio2value(0.5)) + get_zero_ratio();
|
||||||
else
|
else
|
||||||
return value2ratio(_trig_value);
|
return value2ratio(_trig_value);
|
||||||
@ -456,8 +475,9 @@ void DsoSignal::set_trig_vpos(int pos, bool delta_change)
|
|||||||
|
|
||||||
void DsoSignal::set_trig_ratio(double ratio, bool delta_change)
|
void DsoSignal::set_trig_ratio(double ratio, bool delta_change)
|
||||||
{
|
{
|
||||||
double delta = ratio;
|
double delta = ratio;
|
||||||
if (_dev_inst->name() == "DSLogic") {
|
|
||||||
|
if (session->get_device()->name() == "DSLogic") {
|
||||||
delta = delta - get_zero_ratio();
|
delta = delta - get_zero_ratio();
|
||||||
delta = min(delta, 0.5);
|
delta = min(delta, 0.5);
|
||||||
delta = max(delta, -0.5);
|
delta = max(delta, -0.5);
|
||||||
@ -470,7 +490,7 @@ void DsoSignal::set_trig_ratio(double ratio, bool delta_change)
|
|||||||
_trig_value = std::min(std::max(_trig_value, margin), (ratio2value(1) - margin));
|
_trig_value = std::min(std::max(_trig_value, margin), (ratio2value(1) - margin));
|
||||||
if (delta_change)
|
if (delta_change)
|
||||||
_trig_delta = get_trig_vrate() - get_zero_ratio();
|
_trig_delta = get_trig_vrate() - get_zero_ratio();
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE,
|
||||||
g_variant_new_byte(_trig_value));
|
g_variant_new_byte(_trig_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,8 +506,9 @@ double DsoSignal::get_zero_ratio()
|
|||||||
|
|
||||||
int DsoSignal::get_hw_offset()
|
int DsoSignal::get_hw_offset()
|
||||||
{
|
{
|
||||||
int hw_offset = 0;
|
int hw_offset = 0;
|
||||||
GVariant *gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET);
|
|
||||||
|
GVariant *gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
hw_offset = g_variant_get_uint16(gvar);
|
hw_offset = g_variant_get_uint16(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -505,8 +526,8 @@ void DsoSignal::set_zero_vpos(int pos)
|
|||||||
|
|
||||||
void DsoSignal::set_zero_ratio(double ratio)
|
void DsoSignal::set_zero_ratio(double ratio)
|
||||||
{
|
{
|
||||||
_zero_offset = ratio2value(ratio);
|
_zero_offset = ratio2value(ratio);
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
|
||||||
g_variant_new_uint16(_zero_offset));
|
g_variant_new_uint16(_zero_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,8 +535,9 @@ void DsoSignal::set_factor(uint64_t factor)
|
|||||||
{
|
{
|
||||||
if (enabled()) {
|
if (enabled()) {
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
uint64_t prefactor = 0;
|
uint64_t prefactor = 0;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
|
||||||
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
prefactor = g_variant_get_uint64(gvar);
|
prefactor = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -525,7 +547,7 @@ void DsoSignal::set_factor(uint64_t factor)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prefactor != factor) {
|
if (prefactor != factor) {
|
||||||
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR,
|
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR,
|
||||||
g_variant_new_uint64(factor));
|
g_variant_new_uint64(factor));
|
||||||
_vDial->set_factor(factor);
|
_vDial->set_factor(factor);
|
||||||
_view->set_update(_viewport, true);
|
_view->set_update(_viewport, true);
|
||||||
@ -537,8 +559,9 @@ void DsoSignal::set_factor(uint64_t factor)
|
|||||||
uint64_t DsoSignal::get_factor()
|
uint64_t DsoSignal::get_factor()
|
||||||
{
|
{
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
uint64_t factor;
|
uint64_t factor;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
|
||||||
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
factor = g_variant_get_uint64(gvar);
|
factor = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -706,11 +729,12 @@ void DsoSignal::paint_prepare()
|
|||||||
if (!snapshot->has_data(get_index()))
|
if (!snapshot->has_data(get_index()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const uint16_t enabled_channels = snapshot->get_channel_num();
|
const uint16_t enabled_channels = snapshot->get_channel_num();
|
||||||
if (_view->session().trigd()) {
|
|
||||||
if (get_index() == _view->session().trigd_ch()) {
|
if (session->trigd()) {
|
||||||
|
if (get_index() == session->trigd_ch()) {
|
||||||
uint8_t slope = DSO_TRIGGER_RISING;
|
uint8_t slope = DSO_TRIGGER_RISING;
|
||||||
GVariant *gvar = _view->session().get_device()->get_config(NULL, NULL, SR_CONF_TRIGGER_SLOPE);
|
GVariant *gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_TRIGGER_SLOPE);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
slope = g_variant_get_byte(gvar);
|
slope = g_variant_get_byte(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -751,7 +775,7 @@ void DsoSignal::paint_back(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
const int height = get_view_rect().height();
|
const int height = get_view_rect().height();
|
||||||
const int width = right - left;
|
const int width = right - left;
|
||||||
|
|
||||||
fore.setAlpha(View::BackAlpha);
|
fore.setAlpha(View::BackAlpha);
|
||||||
|
|
||||||
@ -764,8 +788,9 @@ void DsoSignal::paint_back(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
// draw zoom region
|
// draw zoom region
|
||||||
fore.setAlpha(View::ForeAlpha);
|
fore.setAlpha(View::ForeAlpha);
|
||||||
p.setPen(fore);
|
p.setPen(fore);
|
||||||
const uint64_t sample_len = _view->session().cur_samplelimits();
|
|
||||||
const double samplerate = _view->session().cur_snap_samplerate();
|
const uint64_t sample_len = session->cur_samplelimits();
|
||||||
|
const double samplerate = session->cur_snap_samplerate();
|
||||||
const double samples_per_pixel = samplerate * _view->scale();
|
const double samples_per_pixel = samplerate * _view->scale();
|
||||||
const double shown_rate = min(samples_per_pixel * width * 1.0 / sample_len, 1.0);
|
const double shown_rate = min(samples_per_pixel * width * 1.0 / sample_len, 1.0);
|
||||||
const double start = _view->offset() * samples_per_pixel;
|
const double start = _view->offset() * samples_per_pixel;
|
||||||
@ -851,8 +876,8 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
const uint16_t enabled_channels = snapshot->get_channel_num();
|
const uint16_t enabled_channels = snapshot->get_channel_num();
|
||||||
const double pixels_offset = offset;
|
const double pixels_offset = offset;
|
||||||
const double samplerate = _data->samplerate();
|
const double samplerate = _data->samplerate();
|
||||||
//const double samplerate = _dev_inst->get_sample_rate();
|
//const double samplerate = session->get_device()->get_sample_rate();
|
||||||
//const double samplerate = _view->session().cur_snap_samplerate();
|
//const double samplerate = session->cur_snap_samplerate();
|
||||||
const int64_t last_sample = max((int64_t)(snapshot->get_sample_count() - 1), (int64_t)0);
|
const int64_t last_sample = max((int64_t)(snapshot->get_sample_count() - 1), (int64_t)0);
|
||||||
const double samples_per_pixel = samplerate * scale;
|
const double samples_per_pixel = samplerate * scale;
|
||||||
const double start = offset * samples_per_pixel - _view->trig_hoff();
|
const double start = offset * samples_per_pixel - _view->trig_hoff();
|
||||||
@ -876,8 +901,9 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
pixels_offset, samples_per_pixel, enabled_channels);
|
pixels_offset, samples_per_pixel, enabled_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_status status;
|
sr_status status;
|
||||||
if (sr_status_get(_dev_inst->dev_inst(), &status, false) == SR_OK) {
|
|
||||||
|
if (session->get_device()->get_device_status(status, false)) {
|
||||||
_mValid = true;
|
_mValid = true;
|
||||||
if (status.measure_valid) {
|
if (status.measure_valid) {
|
||||||
_min = (index == 0) ? status.ch0_min : status.ch1_min;
|
_min = (index == 0) ? status.ch0_min : status.ch1_min;
|
||||||
@ -890,7 +916,7 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
const uint32_t count = (index == 0) ? status.ch0_cyc_cnt : status.ch1_cyc_cnt;
|
const uint32_t count = (index == 0) ? status.ch0_cyc_cnt : status.ch1_cyc_cnt;
|
||||||
const bool plevel = (index == 0) ? status.ch0_plevel : status.ch1_plevel;
|
const bool plevel = (index == 0) ? status.ch0_plevel : status.ch1_plevel;
|
||||||
const bool startXORend = (index == 0) ? (status.ch0_cyc_llen == 0) : (status.ch1_cyc_llen == 0);
|
const bool startXORend = (index == 0) ? (status.ch0_cyc_llen == 0) : (status.ch1_cyc_llen == 0);
|
||||||
const uint16_t total_channels = g_slist_length(_dev_inst->dev_inst()->channels);
|
const uint16_t total_channels = g_slist_length(session->get_device()->get_channels());
|
||||||
const double tfactor = (total_channels / enabled_channels) * SR_GHZ(1) * 1.0 / samplerate;
|
const double tfactor = (total_channels / enabled_channels) * SR_GHZ(1) * 1.0 / samplerate;
|
||||||
|
|
||||||
double samples = (index == 0) ? status.ch0_cyc_tlen : status.ch1_cyc_tlen;
|
double samples = (index == 0) ? status.ch0_cyc_tlen : status.ch1_cyc_tlen;
|
||||||
@ -925,7 +951,7 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
if (!_show)
|
if (!_show)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(_view);
|
assert(_view);
|
||||||
|
|
||||||
fore.setAlpha(View::BackAlpha);
|
fore.setAlpha(View::BackAlpha);
|
||||||
QPen pen(fore);
|
QPen pen(fore);
|
||||||
@ -999,7 +1025,7 @@ void DsoSignal::paint_fore(QPainter &p, int left, int right, QColor fore, QColor
|
|||||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "T");
|
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "T");
|
||||||
|
|
||||||
// Paint measure
|
// Paint measure
|
||||||
if (_view->session().get_capture_state() == SigSession::Stopped)
|
if (session->is_stopped_status())
|
||||||
paint_hover_measure(p, fore, back);
|
paint_hover_measure(p, fore, back);
|
||||||
|
|
||||||
// autoset
|
// autoset
|
||||||
@ -1117,7 +1143,7 @@ void DsoSignal::paint_envelope(QPainter &p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore)
|
void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore)
|
||||||
{
|
{
|
||||||
p.setRenderHint(QPainter::Antialiasing, true);
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
QColor foreBack = fore;
|
QColor foreBack = fore;
|
||||||
@ -1158,7 +1184,7 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QCol
|
|||||||
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, (_acCoupling == SR_GND_COUPLING) ? tr(strings[2]):
|
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, (_acCoupling == SR_GND_COUPLING) ? tr(strings[2]):
|
||||||
(_acCoupling == SR_DC_COUPLING) ? tr(strings[3]) : tr(strings[4]));
|
(_acCoupling == SR_DC_COUPLING) ? tr(strings[3]) : tr(strings[4]));
|
||||||
|
|
||||||
if (!_dev_inst->name().contains("virtual")) {
|
if (session->get_device()->is_hardware()) {
|
||||||
p.setPen(Qt::transparent);
|
p.setPen(Qt::transparent);
|
||||||
p.setBrush(enabled() ? (auto_rect.contains(pt) ? _colour.darker() : _colour) : foreBack);
|
p.setBrush(enabled() ? (auto_rect.contains(pt) ? _colour.darker() : _colour) : foreBack);
|
||||||
p.drawRect(auto_rect);
|
p.drawRect(auto_rect);
|
||||||
@ -1169,7 +1195,7 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QCol
|
|||||||
// paint the probe factor selector
|
// paint the probe factor selector
|
||||||
GVariant* gvar;
|
GVariant* gvar;
|
||||||
uint64_t factor;
|
uint64_t factor;
|
||||||
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
factor = g_variant_get_uint64(gvar);
|
factor = g_variant_get_uint64(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -1196,7 +1222,7 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt, QCol
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DsoSignal::mouse_press(int right, const QPoint pt)
|
bool DsoSignal::mouse_press(int right, const QPoint pt)
|
||||||
{
|
{
|
||||||
int y = get_y();
|
int y = get_y();
|
||||||
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
|
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
|
||||||
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
|
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
|
||||||
@ -1207,7 +1233,7 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
|
|||||||
const QRectF x100_rect = get_rect(DSO_X100, y, right);
|
const QRectF x100_rect = get_rect(DSO_X100, y, right);
|
||||||
|
|
||||||
if (chEn_rect.contains(pt)) {
|
if (chEn_rect.contains(pt)) {
|
||||||
if (_dev_inst->name() != "virtual-session" &&
|
if (session->get_device()->name() != "virtual-session" &&
|
||||||
!_en_lock) {
|
!_en_lock) {
|
||||||
set_enable(!enabled());
|
set_enable(!enabled());
|
||||||
}
|
}
|
||||||
@ -1218,14 +1244,14 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
|
|||||||
go_vDialNext(true);
|
go_vDialNext(true);
|
||||||
else
|
else
|
||||||
go_vDialPre(true);
|
go_vDialPre(true);
|
||||||
} else if (_dev_inst->name() != "virtual-session" &&
|
} else if (session->get_device()->name() != "virtual-session" &&
|
||||||
acdc_rect.contains(pt)) {
|
acdc_rect.contains(pt)) {
|
||||||
if (_dev_inst->name() == "DSLogic")
|
if (session->get_device()->name() == "DSLogic")
|
||||||
set_acCoupling((get_acCoupling()+1)%2);
|
set_acCoupling((get_acCoupling()+1)%2);
|
||||||
else
|
else
|
||||||
set_acCoupling((get_acCoupling()+1)%2);
|
set_acCoupling((get_acCoupling()+1)%2);
|
||||||
} else if (auto_rect.contains(pt)) {
|
} else if (auto_rect.contains(pt)) {
|
||||||
if (!_dev_inst->name().contains("virtual"))
|
if (!session->get_device()->name().contains("virtual"))
|
||||||
auto_start();
|
auto_start();
|
||||||
} else if (x1_rect.contains(pt)) {
|
} else if (x1_rect.contains(pt)) {
|
||||||
set_factor(1);
|
set_factor(1);
|
||||||
@ -1357,20 +1383,21 @@ void DsoSignal::paint_hover_measure(QPainter &p, QColor fore, QColor back)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DsoSignal::auto_set()
|
void DsoSignal::auto_set()
|
||||||
{
|
{
|
||||||
if (_view->session().get_capture_state() == SigSession::Stopped) {
|
if (session->is_stopped_status()) {
|
||||||
if (_autoV)
|
if (_autoV)
|
||||||
autoV_end();
|
autoV_end();
|
||||||
if (_autoH)
|
if (_autoH)
|
||||||
autoH_end();
|
autoH_end();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (_autoH && _autoV && get_zero_ratio() != 0.5) {
|
if (_autoH && _autoV && get_zero_ratio() != 0.5) {
|
||||||
set_zero_ratio(0.5);
|
set_zero_ratio(0.5);
|
||||||
}
|
}
|
||||||
if (_mValid && !_view->session().get_data_auto_lock()) {
|
if (_mValid && !session->get_data_auto_lock()) {
|
||||||
if (_autoH) {
|
if (_autoH) {
|
||||||
bool roll = false;
|
bool roll = false;
|
||||||
GVariant *gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_ROLL);
|
GVariant *gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_ROLL);
|
||||||
if (gvar != NULL) {
|
if (gvar != NULL) {
|
||||||
roll = g_variant_get_boolean(gvar);
|
roll = g_variant_get_boolean(gvar);
|
||||||
g_variant_unref(gvar);
|
g_variant_unref(gvar);
|
||||||
@ -1414,7 +1441,7 @@ void DsoSignal::auto_set()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_autoH || _autoV)
|
if (_autoH || _autoV)
|
||||||
_view->session().data_auto_lock(AutoLock);
|
session->data_auto_lock(AutoLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1446,11 +1473,12 @@ void DsoSignal::auto_end()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DsoSignal::auto_start()
|
void DsoSignal::auto_start()
|
||||||
{
|
{
|
||||||
if (_autoV || _autoH)
|
if (_autoV || _autoH)
|
||||||
return;
|
return;
|
||||||
if (_view->session().get_capture_state() == SigSession::Running) {
|
|
||||||
_view->session().data_auto_lock(AutoLock);
|
if (session->is_running_status()) {
|
||||||
|
session->data_auto_lock(AutoLock);
|
||||||
_autoV = true;
|
_autoV = true;
|
||||||
_autoH = true;
|
_autoH = true;
|
||||||
_view->auto_trig(get_index());
|
_view->auto_trig(get_index());
|
||||||
@ -1459,12 +1487,13 @@ void DsoSignal::auto_start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DsoSignal::measure(const QPointF &p)
|
bool DsoSignal::measure(const QPointF &p)
|
||||||
{
|
{
|
||||||
_hover_en = false;
|
_hover_en = false;
|
||||||
|
|
||||||
if (!enabled() || !show())
|
if (!enabled() || !show())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_view->session().get_capture_state() != SigSession::Stopped)
|
if (session->is_stopped_status() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QRectF window = get_view_rect();
|
const QRectF window = get_view_rect();
|
||||||
@ -1569,7 +1598,7 @@ QString DsoSignal::get_time(double t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DsoSignal::call_auto_end(){
|
void DsoSignal::call_auto_end(){
|
||||||
_view->session().auto_end();
|
session->auto_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
|
@ -85,7 +85,7 @@ private:
|
|||||||
static const uint16_t MS_RectHeight = 25;
|
static const uint16_t MS_RectHeight = 25;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DsoSignal(DevInst* dev_inst, pv::data::Dso *data,
|
DsoSignal(pv::data::Dso *data,
|
||||||
sr_channel *probe);
|
sr_channel *probe);
|
||||||
|
|
||||||
virtual ~DsoSignal();
|
virtual ~DsoSignal();
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "groupsignal.h"
|
#include "groupsignal.h"
|
||||||
#include "decodetrace.h"
|
#include "decodetrace.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +100,8 @@ int Header::get_nameEditWidth()
|
|||||||
pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt)
|
pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt)
|
||||||
{
|
{
|
||||||
const int w = width();
|
const int w = width();
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
|
|
||||||
for(auto &t : traces)
|
for(auto &t : traces)
|
||||||
{
|
{
|
||||||
@ -124,7 +124,8 @@ void Header::paintEvent(QPaintEvent*)
|
|||||||
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
|
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
|
||||||
|
|
||||||
const int w = width();
|
const int w = width();
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
|
|
||||||
const bool dragging = !_drag_traces.empty();
|
const bool dragging = !_drag_traces.empty();
|
||||||
QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
|
QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
|
||||||
@ -143,7 +144,9 @@ void Header::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
|
|
||||||
if (event->button() & Qt::LeftButton) {
|
if (event->button() & Qt::LeftButton) {
|
||||||
_mouse_down_point = event->pos();
|
_mouse_down_point = event->pos();
|
||||||
@ -166,10 +169,12 @@ void Header::mousePressEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
int action;
|
int action;
|
||||||
const bool instant = _view.session().get_instant();
|
|
||||||
if (instant && _view.session().get_capture_state() == SigSession::Running) {
|
const bool instant = _view.session().is_instant();
|
||||||
|
if (instant && _view.session().is_running_status()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +240,8 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
_view.signals_changed();
|
_view.signals_changed();
|
||||||
_view.set_all_update(true);
|
_view.set_all_update(true);
|
||||||
|
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
|
|
||||||
for(auto &t : traces){
|
for(auto &t : traces){
|
||||||
t->select(false);
|
t->select(false);
|
||||||
@ -287,7 +293,8 @@ void Header::wheelEvent(QWheelEvent *event)
|
|||||||
|
|
||||||
if (isVertical)
|
if (isVertical)
|
||||||
{
|
{
|
||||||
const auto &traces = _view.get_traces(ALL_VIEW);
|
std::vector<Trace*> traces;
|
||||||
|
_view.get_traces(ALL_VIEW, traces);
|
||||||
// Vertical scrolling
|
// Vertical scrolling
|
||||||
double shift = 0;
|
double shift = 0;
|
||||||
|
|
||||||
@ -415,19 +422,6 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
if (!t || !t->selected() || action != Trace::LABEL)
|
if (!t || !t->selected() || action != Trace::LABEL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
|
||||||
* disable group function for v0.97 temporarily
|
|
||||||
*/
|
|
||||||
// QMenu menu(this);
|
|
||||||
// if (t->get_type() == SR_CHANNEL_LOGIC)
|
|
||||||
// menu.addAction(_action_add_group);
|
|
||||||
// else if (t->get_type() == SR_CHANNEL_GROUP)
|
|
||||||
// menu.addAction(_action_del_group);
|
|
||||||
|
|
||||||
// _context_trace = t;
|
|
||||||
// menu.exec(event->globalPos());
|
|
||||||
// _context_trace.r-eset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header::on_action_set_name_triggered()
|
void Header::on_action_set_name_triggered()
|
||||||
@ -440,7 +434,9 @@ void Header::on_action_set_name_triggered()
|
|||||||
context_Trace->set_name(nameEdit->text());
|
context_Trace->set_name(nameEdit->text());
|
||||||
if (context_Trace->get_type() == SR_CHANNEL_LOGIC ||
|
if (context_Trace->get_type() == SR_CHANNEL_LOGIC ||
|
||||||
context_Trace->get_type() == SR_CHANNEL_ANALOG)
|
context_Trace->get_type() == SR_CHANNEL_ANALOG)
|
||||||
sr_dev_probe_name_set(_view.session().get_device()->dev_inst(), context_Trace->get_index(), nameEdit->text().toUtf8().constData());
|
{
|
||||||
|
_view.session().get_device()->set_channel_name(context_Trace->get_index(), nameEdit->text().toUtf8());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nameEdit->hide();
|
nameEdit->hide();
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "../data/dso.h"
|
#include "../data/dso.h"
|
||||||
#include "../data/dsosnapshot.h"
|
#include "../data/dsosnapshot.h"
|
||||||
#include "../sigsession.h"
|
#include "../sigsession.h"
|
||||||
#include "../device/devinst.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user