Config operation API

This commit is contained in:
dreamsourcelabTAI 2023-05-23 10:00:23 +08:00
parent 2757fc3a37
commit b764092b91
19 changed files with 797 additions and 906 deletions

View File

@ -70,56 +70,6 @@ void DeviceAgent::update()
return _di; return _di;
} }
GVariant* DeviceAgent::get_config(const sr_channel *ch, const sr_channel_group *group, int key)
{
assert(_dev_handle);
GVariant *data = NULL;
int ret = ds_get_actived_device_config(ch, group, key, &data);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: 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);
int ret = ds_set_actived_device_config(ch, group, key, data);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: 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;
int ret = ds_get_actived_device_config_list(group, key, &data);
if (ret != SR_OK){
if (ret != SR_ERR_NA)
dsv_detail("%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) bool DeviceAgent::enable_probe(const sr_channel *probe, bool enable)
{ {
assert(_dev_handle); assert(_dev_handle);
@ -349,39 +299,12 @@ GSList *DeviceAgent::get_channels()
return false; return false;
} }
bool DeviceAgent::get_config_value_int16(int key, int &value)
{
GVariant* gvar = get_config(NULL, NULL, key);
if (gvar != NULL) {
value = g_variant_get_int16(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::get_config_value_string(int key, QString &value)
{
GVariant* gvar = get_config(NULL, NULL, key);
if (gvar != NULL) {
const gchar *s = g_variant_get_string(gvar, NULL);
value = QString(s);
g_variant_unref(gvar);
return true;
}
return false;
}
int DeviceAgent::get_operation_mode() int DeviceAgent::get_operation_mode()
{ {
assert(_dev_handle); assert(_dev_handle);
int mode_val = 0; int mode_val = 0;
if (get_config_value_int16(SR_CONF_OPERATION_MODE, mode_val)){ if (get_config_int16(SR_CONF_OPERATION_MODE, mode_val)){
return mode_val; return mode_val;
} }
return -1; return -1;
@ -414,20 +337,125 @@ GSList *DeviceAgent::get_channels()
} }
QString pattern_mode; QString pattern_mode;
if(get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode) == false) if(get_config_string(SR_CONF_PATTERN_MODE, pattern_mode) == false)
{ {
assert(false); assert(false);
} }
return pattern_mode; return pattern_mode;
} }
bool DeviceAgent::set_config_string(int key, const char *value) GVariant* DeviceAgent::get_config_list(const sr_channel_group *group, int key)
{
assert(_dev_handle);
GVariant *data = NULL;
int ret = ds_get_actived_device_config_list(group, key, &data);
if (ret != SR_OK){
if (ret != SR_ERR_NA)
dsv_detail("%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;
}
GVariant* DeviceAgent::get_config(int key, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *data = NULL;
int ret = ds_get_actived_device_config(ch, cg, key, &data);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR:DeviceAgent::get_config, Failed to get value of config id:", key);
}
return data;
}
bool DeviceAgent::have_config(int key, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant *gvar = get_config(key, ch, cg);
if (gvar != NULL){
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config(int key, GVariant *data, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
int ret = ds_set_actived_device_config(ch, cg, key, data);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR:DeviceAgent::set_config, Failed to set value of config id:", key);
return false;
}
config_changed();
return true;
}
bool DeviceAgent::get_config_int32(int key, int &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_int32(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_int32(int key, int value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_int32(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_int32, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_string(int key, QString &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
const gchar *s = g_variant_get_string(gvar, NULL);
value = QString(s);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_string(int key, const char *value, const sr_channel *ch, const sr_channel_group *cg)
{ {
assert(value); assert(value);
assert(_dev_handle); assert(_dev_handle);
GVariant *gvar = g_variant_new_string(value); GVariant *gvar = g_variant_new_string(value);
int ret = ds_set_actived_device_config(NULL, NULL, key, gvar); int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK) if (ret != SR_OK)
{ {
if (ret != SR_ERR_NA) if (ret != SR_ERR_NA)
@ -437,5 +465,209 @@ GSList *DeviceAgent::get_channels()
return true; return true;
} }
bool DeviceAgent::get_config_bool(int key, bool &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
gboolean v = g_variant_get_boolean(gvar);
value = v > 0;
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_bool(int key, bool value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_boolean(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_bool, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_uint64(int key, uint64_t &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_uint64(int key, uint64_t value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_uint64(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_uint64, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_uint16(int key, int &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_uint16(int key, int value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_uint16(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_uint16, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_uint32(int key, uint32_t &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_uint32(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_uint32(int key, uint32_t value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_uint32(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_uint32, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_int16(int key, int &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_int16(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_int16(int key, int value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_int16(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_int16, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_byte(int key, int &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_byte(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_byte(int key, int value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_byte((uint8_t)value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_byte, Failed to set value of config id:", key);
return false;
}
return true;
}
bool DeviceAgent::get_config_double(int key, double &value, const sr_channel *ch, const sr_channel_group *cg)
{
GVariant* gvar = get_config(key, ch, cg);
if (gvar != NULL) {
value = g_variant_get_double(gvar);
g_variant_unref(gvar);
return true;
}
return false;
}
bool DeviceAgent::set_config_double(int key, double value, const sr_channel *ch, const sr_channel_group *cg)
{
assert(_dev_handle);
GVariant *gvar = g_variant_new_double(value);
int ret = ds_set_actived_device_config(ch, cg, key, gvar);
if (ret != SR_OK)
{
if (ret != SR_ERR_NA)
dsv_err("%s%d", "ERROR: DeviceAgent::set_config_double, Failed to set value of config id:", key);
return false;
}
return true;
}
//---------------device config end -----------/ //---------------device config end -----------/

View File

@ -91,22 +91,12 @@ public:
_callback = 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(const sr_channel *probe, bool enable);
bool enable_probe(int probe_index, bool enable); bool enable_probe(int probe_index, bool enable);
bool set_channel_name(int ch_index, const char *name); bool set_channel_name(int ch_index, const char *name);
bool get_config_value_int16(int key, int &value);
bool get_config_value_string(int key, QString &value);
/** /**
* @brief Gets the sample limit from the driver. * @brief Gets the sample limit from the driver.
* *
@ -187,11 +177,42 @@ public:
QString get_demo_operation_mode(); QString get_demo_operation_mode();
bool set_config_string(int key, const char *value); GVariant* get_config_list(const sr_channel_group *group, int key);
GVariant* get_config(int key, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config(int key, GVariant *data, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool have_config(int key, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_string(int key, QString &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_string(int key, const char *value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_bool(int key, bool &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_bool(int key, bool value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_uint64(int key, uint64_t &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_uint64(int key, uint64_t value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_uint16(int key, int &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_uint16(int key, int value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_uint32(int key, uint32_t &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_uint32(int key, uint32_t value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_int16(int key, int &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_int16(int key, int value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_int32(int key, int &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_int32(int key, int value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_byte(int key, int &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_byte(int key, int value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool get_config_double(int key, double &value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
bool set_config_double(int key, double value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL);
private: private:
void config_changed(); void config_changed();
bool is_in_history(ds_device_handle dev_handle); bool is_in_history(ds_device_handle dev_handle);
//---------------device config-----------/ //---------------device config-----------/
public: public:
@ -205,7 +226,6 @@ public:
void free_config(struct sr_config *src); void free_config(struct sr_config *src);
private: private:
ds_device_handle _dev_handle; ds_device_handle _dev_handle;
int _dev_type; int _dev_type;

View File

@ -151,22 +151,11 @@ void Calibration::update_device_info()
assert(probe); assert(probe);
uint64_t vgain = 0, vgain_default = 0; uint64_t vgain = 0, vgain_default = 0;
uint16_t vgain_range = 0; int vgain_range = 0;
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN);
if (gvar != NULL) { _device_agent->get_config_uint64(SR_CONF_PROBE_VGAIN, vgain, probe, NULL);
vgain = g_variant_get_uint64(gvar); _device_agent->get_config_uint64(SR_CONF_PROBE_VGAIN_DEFAULT, vgain_default, probe, NULL);
g_variant_unref(gvar); _device_agent->get_config_uint16(SR_CONF_PROBE_VGAIN_RANGE, vgain_range, probe, NULL);
}
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
if (gvar != NULL) {
vgain_default = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
if (gvar != NULL) {
vgain_range = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
QSlider *gain_slider = new QSlider(Qt::Horizontal, this); QSlider *gain_slider = new QSlider(Qt::Horizontal, this);
gain_slider->setRange(-vgain_range/2, vgain_range/2); gain_slider->setRange(-vgain_range/2, vgain_range/2);
@ -180,16 +169,15 @@ void Calibration::update_device_info()
uint64_t voff = 0; uint64_t voff = 0;
uint16_t voff_range = 0; uint16_t voff_range = 0;
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF); int v;
if (gvar != NULL) {
voff = g_variant_get_uint16(gvar); if (_device_agent->get_config_uint16(SR_CONF_PROBE_PREOFF, v, probe, NULL)) {
g_variant_unref(gvar); voff = (uint64_t)v;
} }
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN); if (_device_agent->get_config_uint16(SR_CONF_PROBE_PREOFF_MARGIN, v, probe, NULL)) {
if (gvar != NULL) { voff_range = (uint16_t)v;
voff_range = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
} }
QSlider *off_slider = new QSlider(Qt::Horizontal, this); QSlider *off_slider = new QSlider(Qt::Horizontal, this);
off_slider->setRange(0, voff_range); off_slider->setRange(0, voff_range);
off_slider->setValue(voff); off_slider->setValue(voff);
@ -201,18 +189,12 @@ void Calibration::update_device_info()
_label_list.push_back(off_label); _label_list.push_back(off_label);
bool comb_comp_en = false; bool comb_comp_en = false;
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN); _device_agent->get_config_bool(SR_CONF_PROBE_COMB_COMP_EN, comb_comp_en);
if (gvar != NULL) {
comb_comp_en = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
if (comb_comp_en) { if (comb_comp_en) {
int16_t comb_comp = 0; int comb_comp = 0;
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_COMB_COMP); _device_agent->get_config_int16(SR_CONF_PROBE_COMB_COMP, comb_comp, probe, NULL);
if (gvar != NULL) {
comb_comp = g_variant_get_int16(gvar);
g_variant_unref(gvar);
}
QSlider *comp_slider = new QSlider(Qt::Horizontal, this); QSlider *comp_slider = new QSlider(Qt::Horizontal, this);
comp_slider->setRange(-127, 127); comp_slider->setRange(-127, 127);
comp_slider->setValue(comb_comp); comp_slider->setValue(comb_comp);
@ -235,14 +217,14 @@ void Calibration::update_device_info()
void Calibration::accept() void Calibration::accept()
{ {
using namespace Qt; using namespace Qt;
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false)); _device_agent->set_config_bool(SR_CONF_CALI, false);
QDialog::accept(); QDialog::accept();
} }
void Calibration::reject() void Calibration::reject()
{ {
using namespace Qt; using namespace Qt;
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(false)); _device_agent->set_config_bool(SR_CONF_CALI, false);
QDialog::reject(); QDialog::reject();
} }
@ -255,21 +237,17 @@ void Calibration::set_value(int value)
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 = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT); if (_device_agent->get_config_uint64(SR_CONF_PROBE_VGAIN_DEFAULT, vgain_default, probe))
if (gvar != NULL) { {
vgain_default = g_variant_get_uint64(gvar); _device_agent->set_config_uint64(SR_CONF_PROBE_VGAIN, value+vgain_default, probe);
g_variant_unref(gvar);
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_VGAIN,
g_variant_new_uint64(value+vgain_default));
} }
break; break;
} else if (sc->objectName() == VOFF+probe->index) { }
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_PREOFF, else if (sc->objectName() == VOFF+probe->index) {
g_variant_new_uint16(value)); _device_agent->set_config_uint16(SR_CONF_PROBE_PREOFF, value, probe);
break; break;
} else if (sc->objectName() == VCOMB+probe->index) { } else if (sc->objectName() == VCOMB+probe->index) {
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_COMB_COMP, _device_agent->set_config_int16(SR_CONF_PROBE_COMB_COMP, value, probe);
g_variant_new_int16(value));
break; break;
} }
} }
@ -279,12 +257,11 @@ void Calibration::on_save()
{ {
this->hide(); this->hide();
QFuture<void> future; QFuture<void> future;
future = QtConcurrent::run([&]{ future = QtConcurrent::run([&]{
//QTime dieTime = QTime::currentTime().addSecs(1); _device_agent->set_config_bool( SR_CONF_ZERO_SET, true);
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_SET,
g_variant_new_boolean(true));
//while( QTime::currentTime() < dieTime );
}); });
Qt::WindowFlags flags = Qt::CustomizeWindowHint; Qt::WindowFlags flags = Qt::CustomizeWindowHint;
QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_CALIBRATION_RESULTS), QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_CALIBRATION_RESULTS),
"Save calibration results... It can take a while."), "Save calibration results... It can take a while."),
@ -307,13 +284,12 @@ void Calibration::on_abort()
{ {
this->hide(); this->hide();
QFuture<void> future; QFuture<void> future;
future = QtConcurrent::run([&]{
//QTime dieTime = QTime::currentTime().addSecs(1); future = QtConcurrent::run([&]{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_LOAD, _device_agent->set_config_bool(SR_CONF_ZERO_LOAD, true);
g_variant_new_boolean(true));
reload_value(); reload_value();
//while( QTime::currentTime() < dieTime );
}); });
Qt::WindowFlags flags = Qt::CustomizeWindowHint; Qt::WindowFlags flags = Qt::CustomizeWindowHint;
QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_RELOAD_CALIBRATION_RESULTS), QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_RELOAD_CALIBRATION_RESULTS),
"Reload last calibration results... It can take a while."), "Reload last calibration results... It can take a while."),
@ -338,35 +314,16 @@ void Calibration::reload_value()
assert(probe); assert(probe);
uint64_t vgain = 0, vgain_default = 0; uint64_t vgain = 0, vgain_default = 0;
uint16_t vgain_range = 0; int vgain_range = 0;
GVariant* gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN); _device_agent->get_config_uint64(SR_CONF_PROBE_VGAIN, vgain, probe, NULL);
if (gvar != NULL) { _device_agent->get_config_uint64(SR_CONF_PROBE_VGAIN_DEFAULT, vgain_default, probe, NULL);
vgain = g_variant_get_uint64(gvar); _device_agent->get_config_uint16(SR_CONF_PROBE_VGAIN_RANGE, vgain_range, probe, NULL);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_DEFAULT);
if (gvar != NULL) {
vgain_default = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_VGAIN_RANGE);
if (gvar != NULL) {
vgain_range = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
uint64_t voff = 0; int voff = 0;
uint16_t voff_range = 0; int voff_range = 0;
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF);
if (gvar != NULL) { _device_agent->get_config_uint16(SR_CONF_PROBE_PREOFF, voff, probe, NULL);
voff = g_variant_get_uint16(gvar); _device_agent->get_config_uint16(SR_CONF_PROBE_PREOFF_MARGIN, voff_range, probe, NULL);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_PREOFF_MARGIN);
if (gvar != NULL) {
voff_range = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
for(std::list<QSlider*>::iterator i = _slider_list.begin(); for(std::list<QSlider*>::iterator i = _slider_list.begin();
i != _slider_list.end(); i++) { i != _slider_list.end(); i++) {
@ -387,8 +344,7 @@ void Calibration::on_reset()
"All calibration settings will become the defualt values!")); "All calibration settings will become the defualt values!"));
if (MsgBox::Confirm(strMsg)) { if (MsgBox::Confirm(strMsg)) {
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_DEFAULT, _device_agent->set_config_bool(SR_CONF_ZERO_DEFAULT, true);
g_variant_new_boolean(true));
reload_value(); reload_value();
} }
} }

View File

@ -144,11 +144,7 @@ DeviceOptions::DeviceOptions(QWidget *parent) :
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 = _device_agent->get_config(NULL, NULL, SR_CONF_OPERATION_MODE); _device_agent->get_config_int16(SR_CONF_OPERATION_MODE, _opt_mode);
if (gvar != NULL) {
_opt_mode = g_variant_get_int16(gvar);
g_variant_unref(gvar);
}
try_resize_scroll(); try_resize_scroll();
@ -282,13 +278,10 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout)
struct sr_list_item *plist = (struct sr_list_item*)g_variant_get_uint64(gvar_opts); struct sr_list_item *plist = (struct sr_list_item*)g_variant_get_uint64(gvar_opts);
g_variant_unref(gvar_opts); g_variant_unref(gvar_opts);
GVariant* mode_var = _device_agent->get_config(NULL, NULL, SR_CONF_CHANNEL_MODE); int ch_mode = 0;
assert(mode_var); _device_agent->get_config_int16(SR_CONF_CHANNEL_MODE, ch_mode);
_channel_mode_indexs.clear(); _channel_mode_indexs.clear();
int ch_mode = g_variant_get_int16(mode_var);
g_variant_unref(mode_var);
while (plist != NULL && plist->id >= 0) while (plist != NULL && plist->id >= 0)
{ {
row1++; row1++;
@ -312,11 +305,7 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout)
} }
} }
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM); _device_agent->get_config_int16(SR_CONF_VLD_CH_NUM, vld_ch_num);
if (gvar != NULL) {
vld_ch_num = g_variant_get_int16(gvar);
g_variant_unref(gvar);
}
// channels // channels
QHBoxLayout *line_lay = NULL; QHBoxLayout *line_lay = NULL;
@ -401,12 +390,10 @@ void DeviceOptions::enable_max_probes() {
cur_ch_num++; cur_ch_num++;
} }
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM); int vld_ch_num;
if (gvar == NULL)
return;
int vld_ch_num = g_variant_get_int16(gvar); if (_device_agent->get_config_int16(SR_CONF_VLD_CH_NUM, vld_ch_num) == false)
g_variant_unref(gvar); return;
while(cur_ch_num < vld_ch_num && cur_ch_num < (int)_probes_checkBox_list.size()) { while(cur_ch_num < vld_ch_num && cur_ch_num < (int)_probes_checkBox_list.size()) {
auto box = _probes_checkBox_list[cur_ch_num]; auto box = _probes_checkBox_list[cur_ch_num];
@ -418,12 +405,10 @@ void DeviceOptions::enable_max_probes() {
} }
void DeviceOptions::enable_all_probes() void DeviceOptions::enable_all_probes()
{ {
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_STREAM); bool stream_mode;
if (gvar != NULL) {
bool stream_mode = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (_device_agent->get_config_bool(SR_CONF_STREAM, stream_mode)) {
if (stream_mode) { if (stream_mode) {
enable_max_probes(); enable_max_probes();
return; return;
@ -448,10 +433,10 @@ void DeviceOptions::zero_adj()
bool bRet = MsgBox::Confirm(strMsg); bool bRet = MsgBox::Confirm(strMsg);
if (bRet) { if (bRet) {
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(true)); _device_agent->set_config_bool(SR_CONF_ZERO, true);
} }
else { else {
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false)); _device_agent->set_config_bool(SR_CONF_ZERO, false);
} }
} }
@ -459,7 +444,7 @@ void DeviceOptions::on_calibration()
{ {
using namespace Qt; using namespace Qt;
QDialog::accept(); QDialog::accept();
_device_agent->set_config(NULL, NULL, SR_CONF_CALI, g_variant_new_boolean(true)); _device_agent->set_config_bool(SR_CONF_CALI, true);
} }
void DeviceOptions::mode_check_timeout() void DeviceOptions::mode_check_timeout()
@ -469,11 +454,8 @@ void DeviceOptions::mode_check_timeout()
bool test; bool test;
int mode; int mode;
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
if (gvar != NULL) {
mode = g_variant_get_int16(gvar);
g_variant_unref(gvar);
if (_device_agent->get_config_int16(SR_CONF_OPERATION_MODE, mode)) {
if (mode != _opt_mode) { if (mode != _opt_mode) {
_opt_mode = mode; _opt_mode = mode;
build_dynamic_panel(); build_dynamic_panel();
@ -481,11 +463,7 @@ void DeviceOptions::mode_check_timeout()
} }
} }
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TEST); if (_device_agent->get_config_bool(SR_CONF_TEST, test)) {
if (gvar != NULL) {
test = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (test) { if (test) {
for (auto box : _probes_checkBox_list) { for (auto box : _probes_checkBox_list) {
box->setCheckState(Qt::Checked); box->setCheckState(Qt::Checked);
@ -509,9 +487,7 @@ void DeviceOptions::channel_check()
} }
} }
assert(mode_index >= 0); assert(mode_index >= 0);
_device_agent->set_config_int16(SR_CONF_CHANNEL_MODE, mode_index);
GVariant* gvar = g_variant_new_int16(mode_index);
_device_agent->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, gvar);
build_dynamic_panel(); build_dynamic_panel();
try_resize_scroll(); try_resize_scroll();
@ -526,8 +502,7 @@ void DeviceOptions::analog_channel_check()
sr_channel *const probe = (sr_channel*)l->data; sr_channel *const probe = (sr_channel*)l->data;
if (sc->property("index").toInt() == probe->index){ if (sc->property("index").toInt() == probe->index){
_device_agent->set_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT, _device_agent->set_config_bool(SR_CONF_PROBE_MAP_DEFAULT, sc->isChecked(), probe);
g_variant_new_boolean(sc->isChecked()));
} }
} }
} }
@ -548,13 +523,10 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc)
if (sc == NULL || !sc->isChecked()) if (sc == NULL || !sc->isChecked())
return; return;
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_STREAM); bool stream_mode;
if (gvar == NULL) if (_device_agent->get_config_bool(SR_CONF_STREAM, stream_mode) == false)
return; return;
bool stream_mode = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (!stream_mode) if (!stream_mode)
return; return;
@ -564,12 +536,10 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc)
cur_ch_num++; cur_ch_num++;
} }
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_VLD_CH_NUM); int vld_ch_num;
if (gvar == NULL) if (_device_agent->get_config_int16(SR_CONF_VLD_CH_NUM, vld_ch_num) == false)
return; return;
int vld_ch_num = g_variant_get_int16(gvar);
g_variant_unref(gvar);
if (cur_ch_num > vld_ch_num) { if (cur_ch_num > vld_ch_num) {
QString msg_str(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_MAX_CHANNEL_COUNT_WARNING), "max count of channels!")); QString msg_str(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_MAX_CHANNEL_COUNT_WARNING), "max count of channels!"));
msg_str = msg_str.replace("{0}", QString::number(vld_ch_num) ); msg_str = msg_str.replace("{0}", QString::number(vld_ch_num) );
@ -598,13 +568,8 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc)
if (ck_index != -1) if (ck_index != -1)
{ {
GVariant* gvar = _device_agent->get_config(_dso_channel_list[ck_index], _device_agent->get_config_bool(SR_CONF_PROBE_MAP_DEFAULT,
NULL, SR_CONF_PROBE_MAP_DEFAULT); map_default, _dso_channel_list[ck_index], NULL);
if (gvar != NULL) {
map_default = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
} }
while(i--) while(i--)
@ -684,11 +649,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout)
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 = _device_agent->get_config(probe, NULL, SR_CONF_PROBE_MAP_DEFAULT); _device_agent->get_config_bool(SR_CONF_PROBE_MAP_DEFAULT, map_default, probe, NULL);
if (gvar != NULL) {
map_default = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
if (map_default) if (map_default)
pow->setEnabled(false); pow->setEnabled(false);
@ -735,11 +696,9 @@ QString DeviceOptions::dynamic_widget(QLayout *lay)
return L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHANNEL), "Channel"); return L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHANNEL), "Channel");
} }
else if (mode == DSO) { else if (mode == DSO) {
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_HAVE_ZERO); bool have_zero;
if (gvar != NULL) {
bool have_zero = g_variant_get_boolean(gvar); if (_device_agent->get_config_bool(SR_CONF_HAVE_ZERO, have_zero)) {
g_variant_unref(gvar);
QGridLayout *grid = dynamic_cast<QGridLayout*>(lay); QGridLayout *grid = dynamic_cast<QGridLayout*>(lay);
assert(grid); assert(grid);

View File

@ -77,11 +77,9 @@ FftOptions::FftOptions(QWidget *parent, SigSession *session) :
// setup _window_combobox _len_combobox // setup _window_combobox _len_combobox
_sample_limit = 0; _sample_limit = 0;
GVariant* gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLELIMITS);
if (gvar != NULL) { if (_session->get_device()->get_config_uint64(SR_CONF_MAX_DSO_SAMPLELIMITS, _sample_limit)) {
_sample_limit = g_variant_get_uint64(gvar) * 0.5; _sample_limit = _sample_limit * 0.5;
g_variant_unref(gvar);
} }
else { else {
dsv_err("%s", "ERROR: config_get SR_CONF_MAX_DSO_SAMPLELIMITS failed."); dsv_err("%s", "ERROR: config_get SR_CONF_MAX_DSO_SAMPLELIMITS failed.");

View File

@ -107,9 +107,9 @@ void WaitingDialog::accept()
QFuture<void> future; QFuture<void> future;
future = QtConcurrent::run([&]{ future = QtConcurrent::run([&]{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_SET, _device_agent->set_config_bool(SR_CONF_ZERO_SET, true);
g_variant_new_boolean(true));
}); });
Qt::WindowFlags flags = Qt::CustomizeWindowHint; Qt::WindowFlags flags = Qt::CustomizeWindowHint;
QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_CALIBRATION_RESULTS), "Save calibration results... It can take a while."), QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SAVE_CALIBRATION_RESULTS), "Save calibration results... It can take a while."),
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags); L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags);
@ -135,10 +135,10 @@ void WaitingDialog::reject()
QFuture<void> future; QFuture<void> future;
future = QtConcurrent::run([&]{ future = QtConcurrent::run([&]{
_device_agent->set_config(NULL, NULL, _key, g_variant_new_boolean(false)); _device_agent->set_config_bool(_key, false);
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_LOAD, _device_agent->set_config_bool(SR_CONF_ZERO_LOAD, true);
g_variant_new_boolean(true));
}); });
Qt::WindowFlags flags = Qt::CustomizeWindowHint; Qt::WindowFlags flags = Qt::CustomizeWindowHint;
QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_LOAD_CURRENT_SETTING), "Load current setting... It can take a while."), QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_LOAD_CURRENT_SETTING), "Load current setting... It can take a while."),
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags); L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags);
@ -177,39 +177,28 @@ void WaitingDialog::changeText()
{ {
tips->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_WAITING), "Waiting")); tips->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_WAITING), "Waiting"));
index = 0; index = 0;
GVariant* gvar;
bool comb_comp_en = false; bool comb_comp_en = false;
bool zero_fgain = false; bool zero_fgain = false;
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_PROBE_COMB_COMP_EN); if (_device_agent->get_config_bool(SR_CONF_PROBE_COMB_COMP_EN, comb_comp_en) && comb_comp_en) {
if (gvar != NULL) {
comb_comp_en = g_variant_get_boolean(gvar); if (_device_agent->get_config_bool(SR_CONF_ZERO_COMB_FGAIN, zero_fgain) && zero_fgain) {
g_variant_unref(gvar);
if (comb_comp_en) { for(auto s : _session->get_signals()){
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO_COMB_FGAIN); if (s->signal_type() == DSO_SIGNAL){
if (gvar != NULL) { view::DsoSignal *dsoSig = (view::DsoSignal*)s;
zero_fgain = g_variant_get_boolean(gvar); dsoSig->set_enable(dsoSig->get_index() == 0);
g_variant_unref(gvar); }
if (zero_fgain) {
for(auto s : _session->get_signals()){
if (s->signal_type() == DSO_SIGNAL){
view::DsoSignal *dsoSig = (view::DsoSignal*)s;
dsoSig->set_enable(dsoSig->get_index() == 0);
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO_COMB, g_variant_new_boolean(true));
}
} }
std::this_thread::sleep_for(std::chrono::milliseconds(100));
_device_agent->set_config_bool(SR_CONF_ZERO_COMB, true);
} }
} }
gvar = _device_agent->get_config(NULL, NULL, _key); bool bzero = false;
if (gvar != NULL) { if (_device_agent->get_config_bool(_key, bzero)) {
bool zero = g_variant_get_boolean(gvar); if (!bzero) {
g_variant_unref(gvar);
if (!zero) {
movie->stop(); movie->stop();
movie->jumpToFrame(0); movie->jumpToFrame(0);
timer->stop(); timer->stop();
@ -218,7 +207,8 @@ void WaitingDialog::changeText()
_button_box.addButton(QDialogButtonBox::Save); _button_box.addButton(QDialogButtonBox::Save);
} }
} }
} else { }
else {
tips->setText(tips->text()+"."); tips->setText(tips->text()+".");
} }
} }

View File

@ -230,9 +230,8 @@ void DsoTriggerDock::auto_trig(int index)
void DsoTriggerDock::pos_changed(int pos) void DsoTriggerDock::pos_changed(int pos)
{ {
int ret; int ret;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_byte(
SR_CONF_HORIZ_TRIGGERPOS, SR_CONF_HORIZ_TRIGGERPOS,pos);
g_variant_new_byte((uint8_t)pos));
if (!ret) { if (!ret) {
if (_session->get_device()->is_hardware()){ if (_session->get_device()->is_hardware()){
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_HOR_TRI_POS_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_HOR_TRI_POS_FAIL),
@ -258,9 +257,8 @@ void DsoTriggerDock::hold_changed(int hold)
_holdoff_slider->setRange(0, 999); _holdoff_slider->setRange(0, 999);
holdoff = _holdoff_slider->value() * _holdoff_comboBox->currentData().toDouble() / 10; holdoff = _holdoff_slider->value() * _holdoff_comboBox->currentData().toDouble() / 10;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_uint64(
SR_CONF_TRIGGER_HOLDOFF, SR_CONF_TRIGGER_HOLDOFF,holdoff);
g_variant_new_uint64(holdoff));
if (!ret) { if (!ret) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_TRI_HOLDOFF_TIME_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_TRI_HOLDOFF_TIME_FAIL),
@ -272,9 +270,7 @@ void DsoTriggerDock::hold_changed(int hold)
void DsoTriggerDock::margin_changed(int margin) void DsoTriggerDock::margin_changed(int margin)
{ {
int ret; int ret;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_byte(SR_CONF_TRIGGER_MARGIN, margin);
SR_CONF_TRIGGER_MARGIN,
g_variant_new_byte(margin));
if (!ret) { if (!ret) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_SENSITIVITY_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_SENSITIVITY_FAIL),
"Change trigger value sensitivity failed!")); "Change trigger value sensitivity failed!"));
@ -299,9 +295,7 @@ void DsoTriggerDock::source_changed()
dsv_info("Set DSO trig type:%d", id); dsv_info("Set DSO trig type:%d", id);
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_byte(SR_CONF_TRIGGER_SOURCE, id);
SR_CONF_TRIGGER_SOURCE,
g_variant_new_byte(id));
if (!ret) { if (!ret) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_SOURCE_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_SOURCE_FAIL),
"Change trigger source failed!")); "Change trigger source failed!"));
@ -317,9 +311,7 @@ void DsoTriggerDock::check_setting()
_ch0a1_radioButton->setChecked(false); _ch0a1_radioButton->setChecked(false);
_ch0o1_radioButton->setChecked(false); _ch0o1_radioButton->setChecked(false);
_session->get_device()->set_config(NULL, NULL, _session->get_device()->set_config_byte(SR_CONF_TRIGGER_SOURCE, int(DSO_TRIGGER_AUTO));
SR_CONF_TRIGGER_SOURCE,
g_variant_new_byte(DSO_TRIGGER_AUTO));
} }
} }
@ -350,9 +342,9 @@ void DsoTriggerDock::channel_changed(int ch)
(void)ch; (void)ch;
int ret; int ret;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_byte(
SR_CONF_TRIGGER_CHANNEL, SR_CONF_TRIGGER_CHANNEL,
g_variant_new_byte(_channel_comboBox->currentData().toInt())); int(_channel_comboBox->currentData().toInt()));
if (!ret) { if (!ret) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_CHANNEL_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_CHANNEL_FAIL),
"Change trigger channel failed!")); "Change trigger channel failed!"));
@ -365,9 +357,9 @@ void DsoTriggerDock::type_changed()
int id = _type_group->checkedId(); int id = _type_group->checkedId();
int ret; int ret;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config_byte(
SR_CONF_TRIGGER_SLOPE, SR_CONF_TRIGGER_SLOPE,
g_variant_new_byte(id)); id);
if (!ret) { if (!ret) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_TYPE_FAIL), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANGE_TYPE_FAIL),
"Change trigger type failed!")); "Change trigger type failed!"));
@ -385,6 +377,7 @@ void DsoTriggerDock::device_change()
void DsoTriggerDock::update_view() void DsoTriggerDock::update_view()
{ {
bool bDisable = _session->get_device()->is_file(); bool bDisable = _session->get_device()->is_file();
bool ret;
for(QAbstractButton * btn : _source_group->buttons()){ for(QAbstractButton * btn : _source_group->buttons()){
btn->setDisabled(bDisable); btn->setDisabled(bDisable);
@ -407,20 +400,17 @@ void DsoTriggerDock::update_view()
return; return;
} }
// TRIGGERPOS int pos;
GVariant* gvar = _session->get_device()->get_config(NULL, NULL, int src;
SR_CONF_HORIZ_TRIGGERPOS); int slope;
if (gvar != NULL) {
uint16_t pos = g_variant_get_byte(gvar); // TRIGGERPOS
g_variant_unref(gvar); if (_session->get_device()->get_config_byte(
SR_CONF_HORIZ_TRIGGERPOS, pos)) {
_position_slider->setValue(pos); _position_slider->setValue(pos);
} }
gvar = _session->get_device()->get_config(NULL, NULL, if (_session->get_device()->get_config_byte(SR_CONF_TRIGGER_SOURCE, src)) {
SR_CONF_TRIGGER_SOURCE);
if (gvar != NULL) {
uint8_t src = g_variant_get_byte(gvar);
g_variant_unref(gvar);
_source_group->button(src)->setChecked(true); _source_group->button(src)->setChecked(true);
} }
@ -434,11 +424,9 @@ void DsoTriggerDock::update_view()
_channel_comboBox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index())); _channel_comboBox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index()));
} }
} }
gvar = _session->get_device()->get_config(NULL, NULL, ret = _session->get_device()->get_config_byte(
SR_CONF_TRIGGER_CHANNEL); SR_CONF_TRIGGER_CHANNEL, src);
if (gvar != NULL) { if (ret) {
uint8_t src = g_variant_get_byte(gvar);
g_variant_unref(gvar);
for (int i = 0; i < _channel_comboBox->count(); i++) { for (int i = 0; i < _channel_comboBox->count(); i++) {
if (src == _channel_comboBox->itemData(i).toInt()) { if (src == _channel_comboBox->itemData(i).toInt()) {
_channel_comboBox->setCurrentIndex(i); _channel_comboBox->setCurrentIndex(i);
@ -448,22 +436,19 @@ void DsoTriggerDock::update_view()
} }
connect(_channel_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(channel_changed(int))); connect(_channel_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(channel_changed(int)));
gvar = _session->get_device()->get_config(NULL, NULL, ret = _session->get_device()->get_config_byte(
SR_CONF_TRIGGER_SLOPE); SR_CONF_TRIGGER_SLOPE, slope);
if (gvar != NULL) { if (ret) {
uint8_t slope = g_variant_get_byte(gvar);
g_variant_unref(gvar);
_type_group->button(slope)->setChecked(true); _type_group->button(slope)->setChecked(true);
} }
disconnect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int))); disconnect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int)));
disconnect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int))); disconnect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int)));
gvar = _session->get_device()->get_config(NULL, NULL,
SR_CONF_TRIGGER_HOLDOFF); uint64_t holdoff;
if (gvar != NULL) { ret = _session->get_device()->get_config_uint64(
uint64_t holdoff = g_variant_get_uint64(gvar); SR_CONF_TRIGGER_HOLDOFF, holdoff);
g_variant_unref(gvar); if (ret) {
auto v = holdoff * 10.0; auto v = holdoff * 10.0;
for (int i=0; i<_holdoff_comboBox->count(); i++) for (int i=0; i<_holdoff_comboBox->count(); i++)
@ -487,11 +472,11 @@ void DsoTriggerDock::update_view()
connect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int))); connect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int)));
disconnect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); disconnect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int)));
gvar = _session->get_device()->get_config(NULL, NULL,
SR_CONF_TRIGGER_MARGIN); int margin;
if (gvar != NULL) { ret = _session->get_device()->get_config_byte(
uint8_t margin = g_variant_get_byte(gvar); SR_CONF_TRIGGER_MARGIN, margin);
g_variant_unref(gvar); if (ret) {
_margin_slider->setValue(margin); _margin_slider->setValue(margin);
} }
connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int)));

View File

@ -54,11 +54,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) :
_cur_ch_num = 16; _cur_ch_num = 16;
if (_session->get_device()->have_instance()) { if (_session->get_device()->have_instance()) {
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TOTAL_CH_NUM); _session->get_device()->get_config_int16(SR_CONF_TOTAL_CH_NUM, _cur_ch_num);
if (gvar != NULL) {
_cur_ch_num = g_variant_get_int16(gvar);
g_variant_unref(gvar);
}
} }
_widget = new QWidget(this); _widget = new QWidget(this);
@ -193,11 +189,7 @@ void TriggerDock::adv_trigger()
{ {
if (_session->get_device()->is_hardware_logic()) { if (_session->get_device()->is_hardware_logic()) {
bool stream = false; bool stream = false;
GVariant *gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_STREAM); _session->get_device()->get_config_bool(SR_CONF_STREAM, stream);
if (gvar != NULL) {
stream = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
if (stream) { if (stream) {
QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_STREAM_NO_AD_TRIGGER), QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_STREAM_NO_AD_TRIGGER),
@ -255,22 +247,16 @@ void TriggerDock::device_updated()
uint64_t hw_depth; uint64_t hw_depth;
bool stream = false; bool stream = false;
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);
int mode = _session->get_device()->get_work_mode(); int mode = _session->get_device()->get_work_mode();
bool ret;
int ch_num;
if (gvar != NULL) { ret = _session->get_device()->get_config_uint64(SR_CONF_HW_DEPTH, hw_depth);
hw_depth = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
if (ret) {
if (mode == LOGIC) { if (mode == LOGIC) {
_session->get_device()->get_config_bool(SR_CONF_STREAM, stream);
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_STREAM);
if (gvar != NULL) {
stream = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
sample_limits = _session->get_device()->get_sample_limit(); sample_limits = _session->get_device()->get_sample_limit();
_adv_radioButton->setEnabled(!stream); _adv_radioButton->setEnabled(!stream);
@ -294,11 +280,8 @@ void TriggerDock::device_updated()
} }
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TOTAL_CH_NUM); ret = _session->get_device()->get_config_int16(SR_CONF_TOTAL_CH_NUM, ch_num);
if (gvar != NULL) { if (ret) {
int ch_num = g_variant_get_int16(gvar);
g_variant_unref(gvar);
if (ch_num != _cur_ch_num) { if (ch_num != _cur_ch_num) {
_cur_ch_num = ch_num; _cur_ch_num = ch_num;
setup_adv_tab(); setup_adv_tab();

View File

@ -668,7 +668,7 @@ namespace pv
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 = _device_agent->get_config_info(options[i]); const struct sr_config_info *const info = _device_agent->get_config_info(options[i]);
gvar = _device_agent->get_config(NULL, NULL, info->key); gvar = _device_agent->get_config(info->key);
if (gvar != NULL) if (gvar != NULL)
{ {
if (info->datatype == SR_T_BOOL) if (info->datatype == SR_T_BOOL)
@ -870,7 +870,7 @@ namespace pv
continue; continue;
} }
bool bFlag = _device_agent->set_config(NULL, NULL, info->key, gvar); bool bFlag = _device_agent->set_config(info->key, gvar);
if (!bFlag){ if (!bFlag){
dsv_err("Set device config option failed, id:%d, code:%d", info->key, id); dsv_err("Set device config option failed, id:%d, code:%d", info->key, id);
} }
@ -1450,19 +1450,12 @@ namespace pv
if (_device_agent->is_hardware()) if (_device_agent->is_hardware())
{ {
int usb_speed = LIBUSB_SPEED_HIGH; int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB_SPEED); _device_agent->get_config_int32(SR_CONF_USB_SPEED, usb_speed);
if (gvar != NULL)
{
usb_speed = g_variant_get_int32(gvar);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB30_SUPPORT); bool usb30_support = false;
if (gvar != NULL)
{
bool usb30_support = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (_device_agent->get_config_bool(SR_CONF_USB30_SUPPORT, usb30_support))
{
dsv_info("The device's USB module version: %d.0", usb30_support ? 3 : 2); dsv_info("The device's USB module version: %d.0", usb30_support ? 3 : 2);
int cable_ver = 1; int cable_ver = 1;
@ -1542,12 +1535,10 @@ namespace pv
if (device_agent->is_file() && device_agent->is_new_device()) if (device_agent->is_file() && device_agent->is_new_device())
{ {
if (device_agent->get_work_mode() == LOGIC) if (device_agent->get_work_mode() == LOGIC)
{ {
GVariant *gvar = device_agent->get_config(NULL, NULL, SR_CONF_FILE_VERSION); int version = -1;
if (gvar != NULL) if (device_agent->get_config_int16(SR_CONF_FILE_VERSION, version))
{ {
int16_t version = g_variant_get_int16(gvar);
g_variant_unref(gvar);
if (version == 1) if (version == 1)
{ {
QString strMsg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHECK_SESSION_FILE_VERSION_ERROR), QString strMsg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHECK_SESSION_FILE_VERSION_ERROR),
@ -1763,14 +1754,9 @@ namespace pv
{ {
if(_device_agent->get_work_mode() == LOGIC) if(_device_agent->get_work_mode() == LOGIC)
{ {
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE); _pattern_mode = _device_agent->get_demo_operation_mode();
if(gvar != NULL)
{
_pattern_mode = g_variant_get_string(gvar,NULL);
g_variant_unref(gvar);
}
_protocol_widget->del_all_protocol(); _protocol_widget->del_all_protocol();
if(_device_agent->get_work_mode() == LOGIC) if(_device_agent->get_work_mode() == LOGIC)
{ {
_view->auto_set_max_scale(); _view->auto_set_max_scale();
@ -1819,12 +1805,7 @@ namespace pv
if(_device_agent->is_demo()) if(_device_agent->is_demo())
{ {
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE); _pattern_mode = _device_agent->get_demo_operation_mode();
if(gvar != NULL)
{
_pattern_mode = g_variant_get_string(gvar,NULL);
g_variant_unref(gvar);
}
_protocol_widget->del_all_protocol(); _protocol_widget->del_all_protocol();
if(_device_agent->get_work_mode() == LOGIC) if(_device_agent->get_work_mode() == LOGIC)
@ -1935,42 +1916,35 @@ namespace pv
case DSV_MSG_BEGIN_DEVICE_OPTIONS: case DSV_MSG_BEGIN_DEVICE_OPTIONS:
if(_device_agent->is_demo()){ if(_device_agent->is_demo()){
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE); _pattern_mode = _device_agent->get_demo_operation_mode();
if(gvar != NULL)
{
_pattern_mode = g_variant_get_string(gvar,NULL);
g_variant_unref(gvar);
}
} }
break; break;
case DSV_MSG_END_DEVICE_OPTIONS: case DSV_MSG_END_DEVICE_OPTIONS:
if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){ if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){
QString pattern_mode; QString pattern_mode = _device_agent->get_demo_operation_mode();
if(_device_agent->get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode))
if(pattern_mode != _pattern_mode)
{ {
if(pattern_mode != _pattern_mode) _pattern_mode = pattern_mode;
_device_agent->set_config_bool(SR_CONF_DEMO_INIT, true);
_device_agent->update();
_session->init_signals();
update_toolbar_view_status();
_sampling_bar->update_sample_rate_list();
_protocol_widget->del_all_protocol();
if(_pattern_mode != "random")
{ {
_pattern_mode = pattern_mode; _session->set_operation_mode(OPT_SINGLE);
_device_agent->set_config(NULL,NULL,SR_CONF_DEMO_INIT,g_variant_new_boolean(TRUE)); StoreSession ss(_session);
_device_agent->update(); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_session->init_signals(); _session->start_capture(false);
update_toolbar_view_status();
_sampling_bar->update_sample_rate_list();
_protocol_widget->del_all_protocol();
if(_pattern_mode != "random")
{
_session->set_operation_mode(OPT_SINGLE);
StoreSession ss(_session);
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
ss.load_decoders(_protocol_widget, deArray);
_session->start_capture(false);
}
} }
} }
} }
calc_min_height(); calc_min_height();
break; break;
@ -1979,17 +1953,15 @@ namespace pv
if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){ if(_device_agent->is_demo() &&_device_agent->get_work_mode() == LOGIC){
_protocol_widget->del_all_protocol(); _protocol_widget->del_all_protocol();
_session->clear_view_data(); _session->clear_view_data();
QString pattern_mode; QString pattern_mode = _device_agent->get_demo_operation_mode();
if(_device_agent->get_config_value_string(SR_CONF_PATTERN_MODE, pattern_mode)){ if(pattern_mode != "random"){
if(pattern_mode != "random"){ _device_agent->update();
_device_agent->update(); _session->set_operation_mode(OPT_SINGLE);
_session->set_operation_mode(OPT_SINGLE); StoreSession ss(_session);
StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); ss.load_decoders(_protocol_widget, deArray);
ss.load_decoders(_protocol_widget, deArray); }
}
}
} }
break; break;
} }

View File

@ -145,14 +145,14 @@ GVariant* DeviceOptions::config_getter(int key)
{ {
SigSession *session = AppControl::Instance()->GetSession(); SigSession *session = AppControl::Instance()->GetSession();
DeviceAgent *_device_agent = session->get_device(); DeviceAgent *_device_agent = session->get_device();
return _device_agent->get_config(NULL, NULL, key); return _device_agent->get_config(key);
} }
void DeviceOptions::config_setter(int key, GVariant* value) void DeviceOptions::config_setter(int key, GVariant* value)
{ {
SigSession *session = AppControl::Instance()->GetSession(); SigSession *session = AppControl::Instance()->GetSession();
DeviceAgent *_device_agent = session->get_device(); DeviceAgent *_device_agent = session->get_device();
_device_agent->set_config(NULL, NULL, key, value); _device_agent->set_config(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)
@ -316,13 +316,9 @@ void DeviceOptions::bind_bandwidths(const QString &name, const QString label, in
plist = (struct sr_list_item*)g_variant_get_uint64(gvar_list); plist = (struct sr_list_item*)g_variant_get_uint64(gvar_list);
assert(plist); assert(plist);
bw_limit = FALSE; bw_limit = false;
gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_BANDWIDTH); _device_agent->get_config_bool(SR_CONF_BANDWIDTH, bw_limit);
if (gvar_tmp != NULL) {
bw_limit = g_variant_get_boolean(gvar_tmp);
g_variant_unref(gvar_tmp);
}
if (!bw_limit) if (!bw_limit)
return; return;

View File

@ -109,14 +109,14 @@ GVariant* ProbeOptions::config_getter(const struct sr_channel *probe, int key)
{ {
SigSession *session = AppControl::Instance()->GetSession(); SigSession *session = AppControl::Instance()->GetSession();
DeviceAgent *_device_agent = session->get_device(); DeviceAgent *_device_agent = session->get_device();
return _device_agent->get_config(probe, NULL, key); return _device_agent->get_config(key, probe, NULL);
} }
void ProbeOptions::config_setter(struct sr_channel *probe, int key, GVariant* value) void ProbeOptions::config_setter(struct sr_channel *probe, int key, GVariant* value)
{ {
SigSession *session = AppControl::Instance()->GetSession(); SigSession *session = AppControl::Instance()->GetSession();
DeviceAgent *_device_agent = session->get_device(); DeviceAgent *_device_agent = session->get_device();
_device_agent->set_config(probe, NULL, key, value); _device_agent->set_config(key, value, probe, NULL);
} }
void ProbeOptions::bind_bool(const QString &name, const QString label, int key) void ProbeOptions::bind_bool(const QString &name, const QString label, int key)

View File

@ -402,7 +402,7 @@ namespace pv
void SigSession::capture_init() void SigSession::capture_init()
{ {
// update instant setting // update instant setting
_device_agent.set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(_is_instant)); _device_agent.set_config_bool(SR_CONF_INSTANT, _is_instant);
_callback->update_capture(); _callback->update_capture();
set_cur_snap_samplerate(_device_agent.get_sample_rate()); set_cur_snap_samplerate(_device_agent.get_sample_rate());
@ -521,21 +521,15 @@ namespace pv
if (is_loop_mode() && _device_agent.is_demo()) if (is_loop_mode() && _device_agent.is_demo())
{ {
GVariant *gvar = _device_agent.get_config(NULL,NULL,SR_CONF_PATTERN_MODE); QString opt_mode = _device_agent.get_demo_operation_mode();
if(gvar != NULL) if (opt_mode != "random"){
{ set_operation_mode(OPT_SINGLE);
QString rand_mode = g_variant_get_string(gvar,NULL);
g_variant_unref(gvar);
if (rand_mode != "random"){
set_operation_mode(OPT_SINGLE);
}
} }
} }
if (_device_agent.is_hardware() || _device_agent.is_demo()){ if (_device_agent.is_hardware() || _device_agent.is_demo()){
GVariant *val = g_variant_new_boolean(is_loop_mode() && _is_stream_mode); bool bv = is_loop_mode() && _is_stream_mode;
_device_agent.set_config(NULL, NULL, SR_CONF_LOOP_MODE, val); _device_agent.set_config_bool(SR_CONF_LOOP_MODE, bv);
} }
} }
@ -692,13 +686,8 @@ namespace pv
bool wait_upload = false; bool wait_upload = false;
if (is_single_mode() && _device_agent.get_work_mode() == LOGIC) if (is_single_mode() && _device_agent.get_work_mode() == LOGIC)
{ {
GVariant *gvar = _device_agent.get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD); _device_agent.get_config_bool(SR_CONF_WAIT_UPLOAD, wait_upload);
if (gvar != NULL)
{
wait_upload = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
} }
if (!wait_upload) if (!wait_upload)
@ -1632,10 +1621,9 @@ namespace pv
void SigSession::nodata_timeout() void SigSession::nodata_timeout()
{ {
GVariant *gvar = _device_agent.get_config(NULL, NULL, SR_CONF_TRIGGER_SOURCE); int flag;
if (gvar == NULL) _device_agent.get_config_byte(SR_CONF_TRIGGER_SOURCE, flag);
return; if (flag != DSO_TRIGGER_AUTO)
if (g_variant_get_byte(gvar) != DSO_TRIGGER_AUTO)
{ {
_callback->show_wait_trigger(); _callback->show_wait_trigger();
} }
@ -2148,9 +2136,8 @@ namespace pv
int cur_mode = _device_agent.get_work_mode(); int cur_mode = _device_agent.get_work_mode();
if (cur_mode != mode) if (cur_mode != mode)
{ {
GVariant *val = g_variant_new_int16(mode); _device_agent.set_config_int16(SR_CONF_DEVICE_MODE, mode);
_device_agent.set_config(NULL, NULL, SR_CONF_DEVICE_MODE, val);
if (cur_mode == LOGIC){ if (cur_mode == LOGIC){
clear_all_decode_task2(); clear_all_decode_task2();

View File

@ -454,7 +454,6 @@ void StoreSession::save_proc(data::Snapshot *snapshot)
bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str) bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
{ {
GSList *l; GSList *l;
GVariant *gvar;
struct sr_channel *probe; struct sr_channel *probe;
int probecnt; int probecnt;
char *s; char *s;
@ -497,42 +496,33 @@ 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;
uint64_t tmp_u64;
int tmp_u8;
uint32_t tmp_u32;
if (mode == DSO) { if (mode == DSO) {
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_TIMEBASE); if (_session->get_device()->get_config_uint64(SR_CONF_TIMEBASE, tmp_u64)) {
if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
sprintf(meta, "hDiv = %" PRIu64 "\n", tmp_u64); str += meta; sprintf(meta, "hDiv = %" PRIu64 "\n", tmp_u64); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE);
if (gvar != NULL) { if (_session->get_device()->get_config_uint64(SR_CONF_MAX_TIMEBASE, tmp_u64)) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
sprintf(meta, "hDiv max = %" PRIu64 "\n", tmp_u64); str += meta; sprintf(meta, "hDiv max = %" PRIu64 "\n", tmp_u64); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL) { if (_session->get_device()->get_config_uint64(SR_CONF_MIN_TIMEBASE, tmp_u64)) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
sprintf(meta, "hDiv min = %" PRIu64 "\n", tmp_u64); str += meta; sprintf(meta, "hDiv min = %" PRIu64 "\n", tmp_u64); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
if (gvar != NULL) { if (_session->get_device()->get_config_byte(SR_CONF_UNIT_BITS, tmp_u8)) {
uint8_t tmp_u8 = g_variant_get_byte(gvar);
sprintf(meta, "bits = %d\n", tmp_u8); str += meta; sprintf(meta, "bits = %d\n", tmp_u8); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
if (gvar != NULL) { if (_session->get_device()->get_config_uint32(SR_CONF_REF_MIN, tmp_u32)) {
uint32_t tmp_u32 = g_variant_get_uint32(gvar);
sprintf(meta, "ref min = %d\n", tmp_u32); str += meta; sprintf(meta, "ref min = %d\n", tmp_u32); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
if (gvar != NULL) { if (_session->get_device()->get_config_uint32(SR_CONF_REF_MAX, tmp_u32)) {
uint32_t tmp_u32 = g_variant_get_uint32(gvar);
sprintf(meta, "ref max = %d\n", tmp_u32); str += meta; sprintf(meta, "ref max = %d\n", tmp_u32); str += meta;
g_variant_unref(gvar);
} }
} }
else if (mode == LOGIC) { else if (mode == LOGIC) {
@ -544,17 +534,13 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes(); uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
sprintf(meta, "bits = %d\n", tmp_u8*8); str += meta; sprintf(meta, "bits = %d\n", tmp_u8*8); str += meta;
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
if (gvar != NULL) { if (_session->get_device()->get_config_uint32(SR_CONF_REF_MIN, tmp_u32)) {
uint32_t tmp_u32 = g_variant_get_uint32(gvar);
sprintf(meta, "ref min = %d\n", tmp_u32); str += meta; sprintf(meta, "ref min = %d\n", tmp_u32); str += meta;
g_variant_unref(gvar);
} }
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX);
if (gvar != NULL) { if (_session->get_device()->get_config_uint32(SR_CONF_REF_MAX, tmp_u32)) {
uint32_t tmp_u32 = g_variant_get_uint32(gvar);
sprintf(meta, "ref max = %d\n", tmp_u32); str += meta; sprintf(meta, "ref max = %d\n", tmp_u32); str += meta;
g_variant_unref(gvar);
} }
} }
sprintf(meta, "trigger pos = %" PRIu64 "\n", _session->get_trigger_pos()); str += meta; sprintf(meta, "trigger pos = %" PRIu64 "\n", _session->get_trigger_pos()); str += meta;
@ -807,14 +793,11 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
meta.config = g_slist_append(meta.config, src); meta.config = g_slist_append(meta.config, src);
GVariant *gvar; GVariant *gvar;
uint8_t bits=0; int bits=0;
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
if (gvar != NULL) {
bits = g_variant_get_byte(gvar);
g_variant_unref(gvar);
}
gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN);
_session->get_device()->get_config_byte(SR_CONF_UNIT_BITS, bits);
gvar = _session->get_device()->get_config(SR_CONF_REF_MIN);
if (gvar != NULL) { if (gvar != NULL) {
src = _session->get_device()->new_config(SR_CONF_REF_MIN, gvar); src = _session->get_device()->new_config(SR_CONF_REF_MIN, gvar);
g_variant_unref(gvar); g_variant_unref(gvar);
@ -824,8 +807,8 @@ void StoreSession::export_proc(data::Snapshot *snapshot)
} }
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(SR_CONF_REF_MAX);
if (gvar != NULL) { if (gvar != NULL) {
src = _session->get_device()->new_config(SR_CONF_REF_MAX, gvar); src = _session->get_device()->new_config(SR_CONF_REF_MAX, gvar);
g_variant_unref(gvar); g_variant_unref(gvar);

View File

@ -165,13 +165,8 @@ namespace pv
else else
{ {
int usb_speed = LIBUSB_SPEED_HIGH; int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB_SPEED); _device_agent->get_config_int32(SR_CONF_USB_SPEED, usb_speed);
if (gvar != NULL)
{
usb_speed = g_variant_get_int32(gvar);
g_variant_unref(gvar);
}
if (usb_speed == LIBUSB_SPEED_HIGH) if (usb_speed == LIBUSB_SPEED_HIGH)
_device_type.setText("USB 2.0"); _device_type.setText("USB 2.0");
else if (usb_speed == LIBUSB_SPEED_SUPER) else if (usb_speed == LIBUSB_SPEED_SUPER)
@ -231,13 +226,8 @@ namespace pv
else else
{ {
int usb_speed = LIBUSB_SPEED_HIGH; int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_USB_SPEED); _device_agent->get_config_int32(SR_CONF_USB_SPEED, usb_speed);
if (gvar != NULL)
{
usb_speed = g_variant_get_int32(gvar);
g_variant_unref(gvar);
}
if (usb_speed == LIBUSB_SPEED_SUPER) if (usb_speed == LIBUSB_SPEED_SUPER)
_device_type.setIcon(QIcon(":/icons/usb3.svg")); _device_type.setIcon(QIcon(":/icons/usb3.svg"));
else else
@ -289,27 +279,25 @@ namespace pv
update_sample_rate_list(); update_sample_rate_list();
int mode = _device_agent->get_work_mode(); int mode = _device_agent->get_work_mode();
GVariant *gvar; bool zero = false;
bool test;
bool ret;
if (mode == DSO) if (mode == DSO)
{ {
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO);
if (gvar != NULL) _device_agent->get_config_bool(SR_CONF_ZERO, zero);
if (zero)
{ {
bool zero = g_variant_get_boolean(gvar); zero_adj();
g_variant_unref(gvar); return;
if (zero)
{
zero_adj();
return;
}
} }
} }
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TEST);
if (gvar != NULL) ret = _device_agent->get_config_bool(SR_CONF_TEST, test);
if (ret)
{ {
bool test = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (test) if (test)
{ {
update_sample_rate_selector_value(); update_sample_rate_selector_value();
@ -513,20 +501,8 @@ namespace pv
assert(!_updating_sample_count); assert(!_updating_sample_count);
_updating_sample_count = true; _updating_sample_count = true;
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_STREAM); _device_agent->get_config_bool(SR_CONF_STREAM, stream_mode);
if (gvar != NULL) _device_agent->get_config_uint64(SR_CONF_HW_DEPTH, hw_depth);
{
stream_mode = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_HW_DEPTH);
if (gvar != NULL)
{
hw_depth = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
int mode = _device_agent->get_work_mode(); int mode = _device_agent->get_work_mode();
if (mode == LOGIC) if (mode == LOGIC)
@ -548,29 +524,14 @@ namespace pv
if (mode == LOGIC) if (mode == LOGIC)
{ {
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_RLE_SUPPORT); _device_agent->get_config_bool(SR_CONF_RLE_SUPPORT, rle_support);
if (gvar != NULL)
{
rle_support = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
if (rle_support) if (rle_support)
rle_depth = min(hw_depth * SR_KB(1), sw_depth); rle_depth = min(hw_depth * SR_KB(1), sw_depth);
} }
else if (mode == DSO) else if (mode == DSO)
{ {
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE); _device_agent->get_config_uint64(SR_CONF_MAX_TIMEBASE, max_timebase);
if (gvar != NULL) _device_agent->get_config_uint64(SR_CONF_MIN_TIMEBASE, min_timebase);
{
max_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL)
{
min_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
} }
if (0 != _sample_count.count()) if (0 != _sample_count.count())
@ -673,14 +634,13 @@ namespace pv
GVariant *gvar; GVariant *gvar;
double duration; double duration;
uint64_t v;
if (_device_agent->get_work_mode() == DSO) if (_device_agent->get_work_mode() == DSO)
{ {
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TIMEBASE); if (_device_agent->get_config_uint64(SR_CONF_TIMEBASE, v))
if (gvar != NULL)
{ {
duration = g_variant_get_uint64(gvar); duration = (double)v;
g_variant_unref(gvar);
} }
else else
{ {
@ -689,12 +649,10 @@ namespace pv
} }
} }
else else
{ {
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES); if (_device_agent->get_config_uint64(SR_CONF_LIMIT_SAMPLES, v))
if (gvar != NULL)
{ {
duration = g_variant_get_uint64(gvar); duration = (double)v;
g_variant_unref(gvar);
} }
else else
{ {
@ -774,14 +732,8 @@ namespace pv
const uint64_t sample_limit = _device_agent->get_sample_limit(); const uint64_t sample_limit = _device_agent->get_sample_limit();
GVariant *gvar; GVariant *gvar;
uint64_t max_sample_rate; uint64_t max_sample_rate;
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_MAX_DSO_SAMPLERATE);
if (gvar != NULL) if (_device_agent->get_config_uint64(SR_CONF_MAX_DSO_SAMPLERATE, max_sample_rate) == false)
{
max_sample_rate = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
else
{ {
dsv_err("%s", "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed."); dsv_err("%s", "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.");
return -1; return -1;
@ -793,8 +745,7 @@ namespace pv
(_session->get_ch_num(SR_CHANNEL_DSO) ? _session->get_ch_num(SR_CHANNEL_DSO) : 1))); (_session->get_ch_num(SR_CHANNEL_DSO) ? _session->get_ch_num(SR_CHANNEL_DSO) : 1)));
set_sample_rate(sample_rate); set_sample_rate(sample_rate);
_device_agent->set_config(NULL, NULL, SR_CONF_TIMEBASE, _device_agent->set_config_uint64( SR_CONF_TIMEBASE, hori_res);
g_variant_new_uint64(hori_res));
return hori_res; return hori_res;
} }
@ -802,15 +753,9 @@ namespace pv
void SamplingBar::commit_settings() void SamplingBar::commit_settings()
{ {
bool test = false; bool test = false;
if (_device_agent->have_instance()) if (_device_agent->have_instance())
{ {
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TEST); _device_agent->get_config_bool(SR_CONF_TEST, test);
if (gvar != NULL)
{
test = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
} }
if (test) if (test)
@ -830,9 +775,9 @@ namespace pv
if (_device_agent->have_instance()) if (_device_agent->have_instance())
{ {
if (sample_rate != _device_agent->get_sample_rate()) if (sample_rate != _device_agent->get_sample_rate())
_device_agent->set_config(NULL, NULL, _device_agent->set_config_uint64(
SR_CONF_SAMPLERATE, SR_CONF_SAMPLERATE,
g_variant_new_uint64(sample_rate)); sample_rate);
if (_device_agent->get_work_mode() != DSO) if (_device_agent->get_work_mode() != DSO)
{ {
@ -841,14 +786,14 @@ namespace pv
SAMPLES_ALIGN) & SAMPLES_ALIGN) &
~SAMPLES_ALIGN; ~SAMPLES_ALIGN;
if (sample_count != _device_agent->get_sample_limit()) if (sample_count != _device_agent->get_sample_limit())
_device_agent->set_config(NULL, NULL, _device_agent->set_config_uint64(
SR_CONF_LIMIT_SAMPLES, SR_CONF_LIMIT_SAMPLES,
g_variant_new_uint64(sample_count)); sample_count);
bool rle_mode = _sample_count.currentText().contains(RLEString); bool rle_mode = _sample_count.currentText().contains(RLEString);
_device_agent->set_config(NULL, NULL, _device_agent->set_config_bool(
SR_CONF_RLE, SR_CONF_RLE,
g_variant_new_boolean(rle_mode)); rle_mode);
} }
} }
} }
@ -881,29 +826,25 @@ namespace pv
if (_device_agent->get_work_mode() == DSO) if (_device_agent->get_work_mode() == DSO)
{ {
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO); bool zero;
if (gvar != NULL)
{
bool zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
if (zero) bool ret = _device_agent->get_config_bool(SR_CONF_ZERO, zero);
if (ret && zero)
{
QString str1(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_AUTO_CALIB), "Auto Calibration"));
QString str2(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_ADJUST_SAVE), "Please adjust zero skew and save the result"));
bool bRet = MsgBox::Confirm(str1, str2);
if (bRet)
{ {
QString str1(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_AUTO_CALIB), "Auto Calibration")); zero_adj();
QString str2(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_ADJUST_SAVE), "Please adjust zero skew and save the result"));
bool bRet = MsgBox::Confirm(str1, str2);
if (bRet)
{
zero_adj();
}
else
{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
update_view_status();
}
return;
} }
else
{
_device_agent->set_config_bool(SR_CONF_ZERO, false);
update_view_status();
}
return;
} }
} }
@ -947,28 +888,23 @@ namespace pv
if (_device_agent->get_work_mode() == DSO) if (_device_agent->get_work_mode() == DSO)
{ {
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ZERO); bool zero;
if (gvar != NULL) bool ret = _device_agent->get_config_bool(SR_CONF_ZERO, zero);
{ if (ret && zero)
bool zero = g_variant_get_boolean(gvar); {
g_variant_unref(gvar); QString strMsg(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_AUTO_CALIB_START), "Auto Calibration program will be started. Don't connect any probes. \nIt can take a while!"));
if (zero) if (MsgBox::Confirm(strMsg))
{ {
QString strMsg(L_S(STR_PAGE_MSG,S_ID(IDS_MSG_AUTO_CALIB_START), "Auto Calibration program will be started. Don't connect any probes. \nIt can take a while!")); zero_adj();
if (MsgBox::Confirm(strMsg))
{
zero_adj();
}
else
{
_device_agent->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(false));
update_view_status();
}
return;
} }
else
{
_device_agent->set_config_bool(SR_CONF_ZERO, false);
update_view_status();
}
return;
} }
} }
@ -1022,12 +958,7 @@ namespace pv
if (_device_agent->have_instance()) if (_device_agent->have_instance())
{ {
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_TEST); _device_agent->get_config_bool(SR_CONF_TEST, test);
if (gvar != NULL)
{
test = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
} }
if (!test) if (!test)
{ {
@ -1230,7 +1161,7 @@ namespace pv
if (mode == LOGIC && _session->get_device()->is_hardware()) if (mode == LOGIC && _session->get_device()->is_hardware())
{ {
int mode_val = 0; int mode_val = 0;
if (_session->get_device()->get_config_value_int16(SR_CONF_OPERATION_MODE, mode_val)){ if (_session->get_device()->get_config_int16(SR_CONF_OPERATION_MODE, mode_val)){
if (mode_val == LO_OP_INTEST){ if (mode_val == LO_OP_INTEST){
_sample_rate.setEnabled(false); _sample_rate.setEnabled(false);
_sample_count.setEnabled(false); _sample_count.setEnabled(false);
@ -1270,18 +1201,11 @@ namespace pv
if (_session->get_device()->is_demo() && bEnable) if (_session->get_device()->is_demo() && bEnable)
{ {
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_PATTERN_MODE); QString opt_mode = _device_agent->get_demo_operation_mode();
if(gvar != NULL)
{ if (opt_mode != "random" && mode == LOGIC){
QString rand_mode = g_variant_get_string(gvar,NULL); _sample_rate.setEnabled(false);
g_variant_unref(gvar); _sample_count.setEnabled(false);
bool is_rand = rand_mode == "random";
if (!is_rand && mode == LOGIC){
_sample_rate.setEnabled(false);
_sample_count.setEnabled(false);
}
} }
} }
} }

View File

@ -56,41 +56,30 @@ AnalogSignal::AnalogSignal(data::AnalogSnapshot *data, sr_channel *probe) :
_colour = SignalColours[probe->index % countof(SignalColours)]; _colour = SignalColours[probe->index % countof(SignalColours)];
_signal_type = ANALOG_SIGNAL; _signal_type = ANALOG_SIGNAL;
uint32_t ui32;
GVariant *gvar;
// channel bits // channel bits
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS); bool ret = session->get_device()->get_config_byte(SR_CONF_UNIT_BITS, _bits);
if (gvar != NULL) { if (!ret) {
_bits = g_variant_get_byte(gvar);
g_variant_unref(gvar);
}
else {
_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);
} }
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN); ret = session->get_device()->get_config_uint32(SR_CONF_REF_MIN, ui32);
if (gvar != NULL) { if (ret)
_ref_min = g_variant_get_uint32(gvar); _ref_min = (double)ui32;
g_variant_unref(gvar); else
} else {
_ref_min = 1; _ref_min = 1;
}
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX); ret = session->get_device()->get_config_uint32(SR_CONF_REF_MAX, ui32);
if (gvar != NULL) { if (ret)
_ref_max = g_variant_get_uint32(gvar); _ref_max = (double)ui32;
g_variant_unref(gvar); else
} else {
_ref_max = ((1 << _bits) - 1); _ref_max = ((1 << _bits) - 1);
}
// -- vpos // -- vpos
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET); ret = session->get_device()->get_config_uint16( SR_CONF_PROBE_OFFSET, _zero_offset, _probe, NULL);
if (gvar != NULL) { if (!ret) {
_zero_offset = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_OFFSET failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_OFFSET failed.");
} }
} }
@ -126,11 +115,7 @@ AnalogSignal::~AnalogSignal()
int AnalogSignal::get_hw_offset() int AnalogSignal::get_hw_offset()
{ {
int hw_offset = 0; int hw_offset = 0;
GVariant *gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET); session->get_device()->get_config_uint16(SR_CONF_PROBE_HW_OFFSET, hw_offset, _probe, NULL);
if (gvar != NULL) {
hw_offset = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
return hw_offset; return hw_offset;
} }
@ -139,24 +124,24 @@ int AnalogSignal::commit_settings()
int ret; int ret;
// -- enable // -- enable
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN, ret = session->get_device()->set_config_bool(SR_CONF_PROBE_EN,
g_variant_new_boolean(enabled())); enabled(), _probe);
// -- vdiv // -- vdiv
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, ret = session->get_device()->set_config_uint64(SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_probe->vdiv)); _probe->vdiv, _probe, NULL);
// -- coupling // -- coupling
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING, ret = session->get_device()->set_config_byte(SR_CONF_PROBE_COUPLING,
g_variant_new_byte(_probe->coupling)); _probe->coupling, _probe, NULL);
// -- offset // -- offset
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, ret = session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_probe->offset)); _probe->offset, _probe, NULL);
// -- trig_value // -- trig_value
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE, session->get_device()->set_config_byte(SR_CONF_TRIGGER_VALUE,
g_variant_new_byte(_probe->trig_value)); _probe->trig_value, _probe, NULL);
return ret; return ret;
} }
@ -243,77 +228,51 @@ 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 = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_VDIV); session->get_device()->get_config_uint64(SR_CONF_PROBE_VDIV, vdiv, _probe, NULL);
if (gvar != NULL) {
vdiv = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
return vdiv; return vdiv;
} }
uint8_t AnalogSignal::get_acCoupling() uint8_t AnalogSignal::get_acCoupling()
{ {
uint64_t coupling = 0; int coupling = 0;
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING); session->get_device()->get_config_byte(SR_CONF_PROBE_COUPLING, coupling, _probe, NULL);
if (gvar != NULL) {
coupling = g_variant_get_byte(gvar);
g_variant_unref(gvar);
}
return coupling; return coupling;
} }
bool AnalogSignal::get_mapDefault() bool AnalogSignal::get_mapDefault()
{ {
bool isDefault = true; bool isDefault = true;
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_DEFAULT); session->get_device()->get_config_bool(SR_CONF_PROBE_MAP_DEFAULT, isDefault, _probe, NULL);
if (gvar != NULL) {
isDefault = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
return isDefault; return isDefault;
} }
QString AnalogSignal::get_mapUnit() QString AnalogSignal::get_mapUnit()
{ {
QString unit; QString unit;
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_UNIT); session->get_device()->get_config_string(SR_CONF_PROBE_MAP_UNIT, unit, _probe, NULL);
if (gvar != NULL) {
unit = g_variant_get_string(gvar, NULL);
g_variant_unref(gvar);
}
return unit; return unit;
} }
double AnalogSignal::get_mapMin() double AnalogSignal::get_mapMin()
{ {
double min = -1; double min = -1;
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MIN); session->get_device()->get_config_double(SR_CONF_PROBE_MAP_MIN, min, _probe, NULL);
if (gvar != NULL) {
min = g_variant_get_double(gvar);
g_variant_unref(gvar);
}
return min; return min;
} }
double AnalogSignal::get_mapMax() double AnalogSignal::get_mapMax()
{ {
double max = 1; double max = 1;
GVariant* gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MAX); session->get_device()->get_config_double(SR_CONF_PROBE_MAP_MAX, max, _probe, NULL);
if (gvar != NULL) {
max = g_variant_get_double(gvar);
g_variant_unref(gvar);
}
return max; return max;
} }
uint64_t AnalogSignal::get_factor() uint64_t AnalogSignal::get_factor()
{ {
GVariant* gvar;
uint64_t factor; uint64_t factor;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR); bool ret;
if (gvar != NULL) { ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_FACTOR,factor,_probe, NULL);
factor = g_variant_get_uint64(gvar); if (ret) {
g_variant_unref(gvar);
return factor; return factor;
} }
else { else {
@ -364,8 +323,8 @@ void AnalogSignal::set_zero_ratio(double ratio)
return; return;
_zero_offset = ratio2value(ratio); _zero_offset = ratio2value(ratio);
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset)); _zero_offset, _probe, NULL);
} }
double AnalogSignal::get_zero_ratio() double AnalogSignal::get_zero_ratio()

View File

@ -96,10 +96,12 @@ DsoSignal::DsoSignal(data::DsoSnapshot *data,
GVariant *gvar; GVariant *gvar;
GVariantIter iter; GVariantIter iter;
g_variant_iter_init(&iter, gvar_list_vdivs); g_variant_iter_init(&iter, gvar_list_vdivs);
while(NULL != (gvar = g_variant_iter_next_value(&iter))) { while(NULL != (gvar = g_variant_iter_next_value(&iter))) {
vValue.push_back(g_variant_get_uint64(gvar)); vValue.push_back(g_variant_get_uint64(gvar));
g_variant_unref(gvar); g_variant_unref(gvar);
} }
g_variant_unref(gvar_list_vdivs); g_variant_unref(gvar_list_vdivs);
g_variant_unref(gvar_list); g_variant_unref(gvar_list);
} }
@ -138,14 +140,11 @@ void DsoSignal::set_enable(bool enable)
} }
_en_lock = true; _en_lock = true;
GVariant* gvar;
bool cur_enable; bool cur_enable;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_EN); bool ret;
if (gvar != NULL) { ret = session->get_device()->get_config_bool(SR_CONF_PROBE_EN, cur_enable, _probe, NULL);
cur_enable = g_variant_get_boolean(gvar);
g_variant_unref(gvar); if (!ret) {
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_EN failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_EN failed.");
_en_lock = false; _en_lock = false;
return; return;
@ -166,8 +165,8 @@ void DsoSignal::set_enable(bool enable)
QCoreApplication::processEvents(); QCoreApplication::processEvents();
set_vDialActive(false); set_vDialActive(false);
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN, session->get_device()->set_config_bool( SR_CONF_PROBE_EN,
g_variant_new_boolean(enable)); enable, _probe, NULL);
_view->update_hori_res(); _view->update_hori_res();
@ -200,15 +199,15 @@ bool DsoSignal::go_vDialPre(bool manul)
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);
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, session->get_device()->set_config_uint64(SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value())); _vDial->get_value(), _probe, NULL);
if (session->is_stopped_status()) { if (session->is_stopped_status()) {
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value())); session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset)); _zero_offset, _probe, NULL);
_view->vDial_updated(); _view->vDial_updated();
_view->set_update(_viewport, true); _view->set_update(_viewport, true);
@ -235,15 +234,15 @@ bool DsoSignal::go_vDialNext(bool manul)
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);
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, session->get_device()->set_config_uint64(SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value())); _vDial->get_value(), _probe, NULL);
if (session->is_stopped_status()) { if (session->is_stopped_status()) {
session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value())); session->set_stop_scale(session->stop_scale() * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset)); _zero_offset, _probe, NULL);
_view->vDial_updated(); _view->vDial_updated();
_view->set_update(_viewport, true); _view->set_update(_viewport, true);
@ -259,13 +258,14 @@ bool DsoSignal::go_vDialNext(bool manul)
bool DsoSignal::load_settings() bool DsoSignal::load_settings()
{ {
GVariant* gvar; int v;
uint32_t ui32;
bool ret;
// dso channel bits // dso channel bits
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS); ret = session->get_device()->get_config_byte(SR_CONF_UNIT_BITS, v);
if (gvar != NULL) { if (ret) {
_bits = g_variant_get_byte(gvar); _bits = (uint8_t)v;
g_variant_unref(gvar);
} }
else { else {
_bits = DefaultBits; _bits = DefaultBits;
@ -275,39 +275,29 @@ bool DsoSignal::load_settings()
return false; return false;
} }
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MIN); ret = session->get_device()->get_config_uint32(SR_CONF_REF_MIN, ui32);
if (gvar != NULL) { if (ret)
_ref_min = g_variant_get_uint32(gvar); _ref_min = (double)ui32;
g_variant_unref(gvar); else
} else {
_ref_min = 1; _ref_min = 1;
}
gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_REF_MAX); ret = session->get_device()->get_config_uint32(SR_CONF_REF_MAX, ui32);
if (gvar != NULL) { if (ret)
_ref_max = g_variant_get_uint32(gvar); _ref_max = (double)ui32;
g_variant_unref(gvar); else
} else {
_ref_max = ((1 << _bits) - 1); _ref_max = ((1 << _bits) - 1);
}
// -- vdiv // -- vdiv
uint64_t vdiv; uint64_t vdiv;
uint64_t vfactor; uint64_t vfactor;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_VDIV); ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_VDIV, vdiv, _probe, NULL);
if (gvar != NULL) { if (!ret) {
vdiv = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
else {
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 = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR);
if (gvar != NULL) { ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_FACTOR, vfactor, _probe, NULL);
vfactor = g_variant_get_uint64(gvar); if (!ret) {
g_variant_unref(gvar);
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed.");
return false; return false;
} }
@ -316,10 +306,9 @@ bool DsoSignal::load_settings()
_vDial->set_factor(vfactor); _vDial->set_factor(vfactor);
// -- coupling // -- coupling
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_COUPLING); ret = session->get_device()->get_config_byte(SR_CONF_PROBE_COUPLING, v, _probe, NULL);
if (gvar != NULL) { if (ret) {
_acCoupling = g_variant_get_byte(gvar); _acCoupling = uint8_t(v);
g_variant_unref(gvar);
} }
else { else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_COUPLING failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_COUPLING failed.");
@ -327,22 +316,16 @@ bool DsoSignal::load_settings()
} }
// -- vpos // -- vpos
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_OFFSET); ret = session->get_device()->get_config_uint16(SR_CONF_PROBE_OFFSET, _zero_offset, _probe, NULL);
if (gvar != NULL) { if (!ret) {
_zero_offset = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_OFFSET failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_OFFSET failed.");
return false; return false;
} }
// -- trig_value // -- trig_value
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_TRIGGER_VALUE); ret = session->get_device()->get_config_byte(SR_CONF_TRIGGER_VALUE, _trig_value, _probe, NULL);
if (gvar != NULL) { if (ret) {
_trig_value = g_variant_get_byte(gvar);
_trig_delta = get_trig_vrate() - get_zero_ratio(); _trig_delta = get_trig_vrate() - get_zero_ratio();
g_variant_unref(gvar);
} }
else { else {
dsv_err("%s", "ERROR: config_get SR_CONF_TRIGGER_VALUE failed."); dsv_err("%s", "ERROR: config_get SR_CONF_TRIGGER_VALUE failed.");
@ -363,26 +346,26 @@ int DsoSignal::commit_settings()
int ret; int ret;
// -- enable // -- enable
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_EN, ret = session->get_device()->set_config_bool(SR_CONF_PROBE_EN,
g_variant_new_boolean(enabled())); enabled(), _probe, NULL);
// -- vdiv // -- vdiv
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, ret = session->get_device()->set_config_uint64(SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value())); _vDial->get_value(), _probe, NULL);
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR, ret = session->get_device()->set_config_uint64(SR_CONF_PROBE_FACTOR,
g_variant_new_uint64(_vDial->get_factor())); _vDial->get_factor(), _probe, NULL);
// -- coupling // -- coupling
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING, ret = session->get_device()->set_config_byte(SR_CONF_PROBE_COUPLING,
g_variant_new_byte(_acCoupling)); _acCoupling, _probe, NULL);
// -- offset // -- offset
ret = session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, ret = session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset)); _zero_offset, _probe, NULL);
// -- trig_value // -- trig_value
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE, session->get_device()->set_config_byte(SR_CONF_TRIGGER_VALUE,
g_variant_new_byte(_trig_value)); _trig_value, _probe, NULL);
return ret; return ret;
} }
@ -401,8 +384,8 @@ void DsoSignal::set_acCoupling(uint8_t coupling)
{ {
if (enabled()) { if (enabled()) {
_acCoupling = coupling; _acCoupling = coupling;
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_COUPLING, session->get_device()->set_config_byte(SR_CONF_PROBE_COUPLING,
g_variant_new_byte(_acCoupling)); _acCoupling, _probe, NULL);
} }
} }
@ -463,8 +446,8 @@ void DsoSignal::set_trig_ratio(double ratio, bool delta_change)
if (delta_change) if (delta_change)
_trig_delta = get_trig_vrate() - get_zero_ratio(); _trig_delta = get_trig_vrate() - get_zero_ratio();
session->get_device()->set_config(_probe, NULL, SR_CONF_TRIGGER_VALUE, session->get_device()->set_config_byte(SR_CONF_TRIGGER_VALUE,
g_variant_new_byte(_trig_value)); _trig_value, _probe, NULL);
} }
int DsoSignal::get_zero_vpos() int DsoSignal::get_zero_vpos()
@ -479,13 +462,8 @@ double DsoSignal::get_zero_ratio()
int DsoSignal::get_hw_offset() int DsoSignal::get_hw_offset()
{ {
int hw_offset = 0; int hw_offset = 0;
session->get_device()->get_config_uint16(SR_CONF_PROBE_HW_OFFSET, hw_offset, _probe, NULL);
GVariant *gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_HW_OFFSET);
if (gvar != NULL) {
hw_offset = g_variant_get_uint16(gvar);
g_variant_unref(gvar);
}
return hw_offset; return hw_offset;
} }
@ -500,28 +478,25 @@ 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);
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, session->get_device()->set_config_uint16(SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset)); _zero_offset, _probe, NULL);
} }
void DsoSignal::set_factor(uint64_t factor) void DsoSignal::set_factor(uint64_t factor)
{ {
if (enabled()) { if (enabled()) {
GVariant* gvar;
uint64_t prefactor = 0; uint64_t prefactor = 0;
bool ret;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR); ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_FACTOR, prefactor, _probe, NULL);
if (gvar != NULL) { if (!ret) {
prefactor = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed.");
return; return;
} }
if (prefactor != factor) { if (prefactor != factor) {
session->get_device()->set_config(_probe, NULL, SR_CONF_PROBE_FACTOR, session->get_device()->set_config_uint64(SR_CONF_PROBE_FACTOR,
g_variant_new_uint64(factor)); factor, _probe, NULL);
_vDial->set_factor(factor); _vDial->set_factor(factor);
_view->set_update(_viewport, true); _view->set_update(_viewport, true);
_view->update(); _view->update();
@ -530,14 +505,11 @@ void DsoSignal::set_factor(uint64_t factor)
} }
uint64_t DsoSignal::get_factor() uint64_t DsoSignal::get_factor()
{ {
GVariant* gvar;
uint64_t factor; uint64_t factor;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR); bool ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_FACTOR, factor, _probe, NULL);
if (gvar != NULL) { if (ret) {
factor = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
return factor; return factor;
} }
else { else {
@ -690,10 +662,12 @@ void DsoSignal::paint_prepare()
if (session->trigd()) { if (session->trigd()) {
if (get_index() == session->trigd_ch()) { if (get_index() == session->trigd_ch()) {
uint8_t slope = DSO_TRIGGER_RISING; uint8_t slope = DSO_TRIGGER_RISING;
GVariant *gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_TRIGGER_SLOPE); int v;
if (gvar != NULL) { bool ret;
slope = g_variant_get_byte(gvar);
g_variant_unref(gvar); ret = session->get_device()->get_config_byte(SR_CONF_TRIGGER_SLOPE, v);
if (ret) {
slope = (uint8_t)v;
} }
int64_t trig_index = _view->get_trig_cursor()->index(); int64_t trig_index = _view->get_trig_cursor()->index();
@ -1142,14 +1116,11 @@ 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;
uint64_t factor; uint64_t factor;
gvar = session->get_device()->get_config(_probe, NULL, SR_CONF_PROBE_FACTOR); bool ret;
if (gvar != NULL) {
factor = g_variant_get_uint64(gvar); ret = session->get_device()->get_config_uint64(SR_CONF_PROBE_FACTOR, factor, _probe, NULL);
g_variant_unref(gvar); if (!ret) {
}
else {
dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed."); dsv_err("%s", "ERROR: config_get SR_CONF_PROBE_FACTOR failed.");
return; return;
} }
@ -1362,11 +1333,8 @@ void DsoSignal::auto_set()
if (_mValid && !session->get_data_auto_lock()) { if (_mValid && !session->get_data_auto_lock()) {
if (_autoH) { if (_autoH) {
bool roll = false; bool roll = false;
GVariant *gvar = session->get_device()->get_config(NULL, NULL, SR_CONF_ROLL); session->get_device()->get_config_bool(SR_CONF_ROLL, roll);
if (gvar != NULL) {
roll = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
const double hori_res = _view->get_hori_res(); const double hori_res = _view->get_hori_res();
if (_level_valid && ((!roll && _pcount < 3) || _period > 4*hori_res)) { if (_level_valid && ((!roll && _pcount < 3) || _period > 4*hori_res)) {
_view->zoom(-1); _view->zoom(-1);

View File

@ -437,21 +437,20 @@ void View::set_trig_time()
void View::receive_end() void View::receive_end()
{ {
if (_device_agent->get_work_mode() == LOGIC) { if (_device_agent->get_work_mode() == LOGIC) {
GVariant *gvar = _device_agent->get_config(NULL, NULL, SR_CONF_RLE); bool rle = false;
if (gvar != NULL) { uint64_t actual_samples;
bool rle = g_variant_get_boolean(gvar); bool ret;
g_variant_unref(gvar);
if (rle) { ret = _device_agent->get_config_bool(SR_CONF_RLE, rle);
gvar = _device_agent->get_config(NULL, NULL, SR_CONF_ACTUAL_SAMPLES);
if (gvar != NULL) { if (ret && rle) {
uint64_t actual_samples = g_variant_get_uint64(gvar); ret = _device_agent->get_config_uint64(SR_CONF_ACTUAL_SAMPLES, actual_samples);
g_variant_unref(gvar); if (ret) {
if (actual_samples != _session->cur_samplelimits()) { if (actual_samples != _session->cur_samplelimits()) {
_viewbottom->set_rle_depth(actual_samples); _viewbottom->set_rle_depth(actual_samples);
}
} }
} }
} }
} }
_time_viewport->unshow_wait_trigger(); _time_viewport->unshow_wait_trigger();
} }
@ -647,12 +646,14 @@ void View::signals_changed()
} }
if (_device_agent->get_work_mode() == LOGIC) { if (_device_agent->get_work_mode() == LOGIC) {
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_MAX_HEIGHT_VALUE); int v;
bool ret;
if (gvar != NULL) { ret = _device_agent->get_config_byte(SR_CONF_MAX_HEIGHT_VALUE, v);
max_height = (g_variant_get_byte(gvar) + 1) * MaxHeightUnit; if (ret) {
g_variant_unref(gvar); max_height = (v + 1) * MaxHeightUnit;
} }
if (height < 2*actualMargin) { if (height < 2*actualMargin) {
actualMargin /= 2; actualMargin /= 2;
_signalHeight = max(1.0, (_time_viewport->height() _signalHeight = max(1.0, (_time_viewport->height()
@ -1209,15 +1210,13 @@ int View::get_cursor_index_by_key(uint64_t key)
void View::check_calibration() void View::check_calibration()
{ {
if (_device_agent->get_work_mode() == DSO){ if (_device_agent->get_work_mode() == DSO){
GVariant* gvar = _device_agent->get_config(NULL, NULL, SR_CONF_CALI); bool cali = false;
if (gvar != NULL) { _device_agent->get_config_bool(SR_CONF_CALI, cali);
bool cali = g_variant_get_boolean(gvar);
g_variant_unref(gvar); if (cali) {
if (cali) { show_calibration();
show_calibration(); }
} }
}
}
} }
void View::set_scale(double scale) void View::set_scale(double scale)

View File

@ -377,21 +377,15 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
if (_view.session().get_device()->get_work_mode() == DSO if (_view.session().get_device()->get_work_mode() == DSO
&& _view.session().is_running_status()) && _view.session().is_running_status())
{ {
uint8_t type; int type;
bool roll = false; bool roll = false;
QString type_str=""; QString type_str="";
bool ret = false;
GVariant *gvar = _view.session().get_device()->get_config(NULL, NULL, SR_CONF_ROLL); _view.session().get_device()->get_config_bool(SR_CONF_ROLL, roll);
if (gvar != NULL) {
roll = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
gvar = _view.session().get_device()->get_config(NULL, NULL, SR_CONF_TRIGGER_SOURCE);
if (gvar != NULL) {
type = g_variant_get_byte(gvar);
g_variant_unref(gvar);
ret = _view.session().get_device()->get_config_byte(SR_CONF_TRIGGER_SOURCE, type);
if (ret) {
bool bDot = false; bool bDot = false;
if (type == DSO_TRIGGER_AUTO && roll) { if (type == DSO_TRIGGER_AUTO && roll) {

View File

@ -139,25 +139,11 @@ static GString *gen_header(const struct sr_output *o)
g_string_append_printf(header, "; Channels (%d/%d)\n", g_string_append_printf(header, "; Channels (%d/%d)\n",
ctx->num_enabled_channels, num_channels); ctx->num_enabled_channels, num_channels);
// if (ctx->samplerate == 0) {
// if (sr_config_get(o->sdi->driver, o->sdi, NULL, NULL, SR_CONF_SAMPLERATE,
// &gvar) == SR_OK) {
// ctx->samplerate = g_variant_get_uint64(gvar);
// g_variant_unref(gvar);
// }
// }
char *samplerate_s = sr_samplerate_string(ctx->samplerate); char *samplerate_s = sr_samplerate_string(ctx->samplerate);
g_string_append_printf(header, "; Sample rate: %s\n", samplerate_s); g_string_append_printf(header, "; Sample rate: %s\n", samplerate_s);
g_free(samplerate_s); g_free(samplerate_s);
// if (sr_config_get(o->sdi->driver, o->sdi, NULL, NULL, SR_CONF_LIMIT_SAMPLES,
// &gvar) == SR_OK) {
// uint64_t depth = g_variant_get_uint64(gvar);
// g_variant_unref(gvar);
// char *depth_s = sr_samplecount_string(depth);
// g_string_append_printf(header, "; Sample count: %s\n", depth_s);
// g_free(depth_s);
// }
char *depth_s = sr_samplecount_string(ctx->limit_samples); char *depth_s = sr_samplecount_string(ctx->limit_samples);
g_string_append_printf(header, "; Sample count: %s\n", depth_s); g_string_append_printf(header, "; Sample count: %s\n", depth_s);
g_free(depth_s); g_free(depth_s);