2
0
forked from Ivasoft/DSView

Code refactoring 22

This commit is contained in:
dreamsourcelabTAI
2022-09-26 17:43:57 +08:00
parent 34cab3cf23
commit 365dc84b7e
55 changed files with 228 additions and 1234 deletions

View File

@@ -1,99 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sstream>
#include <assert.h>
#include "device.h"
using std::ostringstream;
using std::string;
namespace pv {
namespace device {
Device::Device(sr_dev_inst *sdi) :
_sdi(sdi)
{
assert(_sdi);
}
Device::~Device()
{
}
sr_dev_inst* Device::dev_inst()
{
return _sdi;
}
void Device::use(SigSession *owner)
{
DevInst::use(owner);
sr_session_new();
sr_dev_open(_sdi);
_usable = (_sdi->status == SR_ST_ACTIVE);
if (sr_session_dev_add(_sdi) != SR_OK)
throw QString(tr("Failed to use device."));
}
void Device::release()
{
if (_owner) {
DevInst::release();
sr_session_destroy();
}
sr_dev_close(_sdi);
}
QString Device::format_device_title()
{
ostringstream s;
if (_sdi->model && _sdi->model[0]) {
s << _sdi->model;
if (_sdi->version && _sdi->version[0])
s << ' ';
}
if (_sdi->version && _sdi->version[0])
s << _sdi->version;
return QString::fromStdString(s.str());
}
bool Device::is_trigger_enabled()
{
for (const GSList *l = _sdi->channels; l; l = l->next) {
const sr_channel *const p = (const sr_channel *)l->data;
assert(p);
if (p->trigger && p->trigger[0] != '\0')
return true;
}
return false;
}
} // device
} // pv

View File

@@ -1,54 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DEVICE_DEVICE_H
#define DSVIEW_PV_DEVICE_DEVICE_H
#include "devinst.h"
namespace pv {
namespace device {
class Device : public DevInst
{
public:
Device(sr_dev_inst *dev_inst);
~Device();
sr_dev_inst* dev_inst();
void use(SigSession *owner);
void release();
QString format_device_title();
bool is_trigger_enabled();
private:
sr_dev_inst *const _sdi;
};
} // device
} // pv
#endif // DSVIEW_PV_DEVICE_DEVICE_H

View File

@@ -1,226 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cassert>
#include "devinst.h"
#include "../sigsession.h"
#include "../log.h"
namespace pv {
namespace device {
DevInst::DevInst() :
_owner(NULL),
_usable(true)
{
_id = malloc(1);
_is_file = false;
}
DevInst::~DevInst()
{
assert(_id);
free(_id);
}
void* DevInst::get_id()
{
assert(_id);
return _id;
}
void DevInst::use(SigSession *owner)
{
assert(owner);
_owner = owner;
}
void DevInst::release()
{
if (_owner) {
_owner->release_device(this);
}
}
SigSession* DevInst::owner()
{
return _owner;
}
GVariant* DevInst::get_config(const sr_channel *ch, const sr_channel_group *group, int key)
{
GVariant *data = NULL;
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
if (sr_config_get(sdi->driver, sdi, ch, group, key, &data) != SR_OK)
return NULL;
return data;
}
bool DevInst::set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data)
{
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
if(sr_config_set(sdi, ch, group, key, data) == SR_OK) {
config_changed();
return true;
}
return false;
}
GVariant* DevInst::list_config(const sr_channel_group *group, int key)
{
GVariant *data = NULL;
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
if (sr_config_list(sdi->driver, sdi, group, key, &data) != SR_OK)
return NULL;
return data;
}
void DevInst::enable_probe(const sr_channel *probe, bool enable)
{
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
for (const GSList *p = sdi->channels; p; p = p->next)
if (probe == p->data) {
const_cast<sr_channel*>(probe)->enabled = enable;
config_changed();
return;
}
// Probe was not found in the device
assert(0);
}
uint64_t DevInst::get_sample_limit()
{
uint64_t sample_limit;
GVariant* gvar = get_config(NULL, NULL, SR_CONF_LIMIT_SAMPLES);
if (gvar != NULL) {
sample_limit = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
} else {
sample_limit = 0U;
}
return sample_limit;
}
uint64_t DevInst::get_sample_rate()
{
uint64_t sample_rate;
GVariant* gvar = get_config(NULL, NULL, SR_CONF_SAMPLERATE);
if (gvar != NULL) {
sample_rate = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
} else {
sample_rate = 0U;
}
return sample_rate;
}
uint64_t DevInst::get_time_base()
{
uint64_t time_base;
GVariant* gvar = get_config(NULL, NULL, SR_CONF_TIMEBASE);
if (gvar != NULL) {
time_base = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
} else {
time_base = 0U;
}
return time_base;
}
double DevInst::get_sample_time()
{
uint64_t sample_rate = get_sample_rate();
uint64_t sample_limit = get_sample_limit();
double sample_time;
if (sample_rate == 0)
sample_time = 0;
else
sample_time = sample_limit * 1.0 / sample_rate;
return sample_time;
}
const GSList* DevInst::get_dev_mode_list()
{
assert(_owner);
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
return sr_dev_mode_list(sdi);
}
QString DevInst::name()
{
sr_dev_inst *const sdi = dev_inst();
assert(sdi);
return QString::fromLocal8Bit(sdi->driver->name);
}
bool DevInst::is_trigger_enabled()
{
return false;
}
void DevInst::start()
{
if (sr_session_start() != SR_OK)
throw tr("Failed to start session.");
//assert(false);
}
void DevInst::run()
{
dsv_info("%s", "session run loop start");
int ret = sr_session_run();
if (ret != SR_OK){
dsv_err("%s", "start session error!");
}
dsv_info("%s", "session run loop end");
}
void DevInst::stop()
{
sr_session_stop();
}
bool DevInst::is_usable()
{
return _usable;
}
void DevInst::destroy(){
release();
//delete this; //do not to destroy
}
} // device
} // pv

View File

@@ -1,148 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DEVICE_DEVINST_H
#define DSVIEW_PV_DEVICE_DEVINST_H
#include <QObject>
#include <string>
#include <glib.h>
#include <stdint.h>
#include <libsigrok.h>
struct sr_dev_inst;
struct sr_channel;
struct sr_channel_group;
namespace pv {
class SigSession;
namespace device {
class DevInst : public QObject
{
Q_OBJECT
protected:
DevInst();
virtual ~DevInst();
public:
SigSession* owner();
GVariant* get_config(const sr_channel *ch, const sr_channel_group *group, int key);
bool set_config(sr_channel *ch, sr_channel_group *group, int key, GVariant *data);
GVariant* list_config(const sr_channel_group *group, int key);
void enable_probe(const sr_channel *probe, bool enable = true);
/**
* @brief Gets the sample limit from the driver.
*
* @return The returned sample limit from the driver, or 0 if the
* sample limit could not be read.
*/
uint64_t get_sample_limit();
/**
* @brief Gets the sample rate from the driver.
*
* @return The returned sample rate from the driver, or 0 if the
* sample rate could not be read.
*/
uint64_t get_sample_rate();
/**
* @brief Gets the sample time from the driver.
*
* @return The returned sample time from the driver, or 0 if the
* sample time could not be read.
*/
double get_sample_time();
/**
* @brief Gets the time base from the driver.
*
* @return The returned time base from the driver, or 0 if the
* time base could not be read.
*/
uint64_t get_time_base();
/**
* @brief Gets the device mode list from the driver.
*
* @return The returned device mode list from the driver, or NULL if the
* mode list could not be read.
*/
const GSList *get_dev_mode_list();
/**
* @brief Get the device name from the driver
*
* @return device name
*/
QString name();
bool is_usable();
void destroy();
inline bool is_file(){
return _is_file;
}
public:
virtual void start();
virtual void run();
virtual void stop();
virtual void* get_id();
virtual sr_dev_inst* dev_inst() = 0;
virtual void use(SigSession *owner);
virtual void release();
virtual bool is_trigger_enabled();
virtual QString format_device_title() = 0;
signals:
void device_updated();
void config_changed();
protected:
SigSession *_owner;
void *_id;
bool _usable;
bool _is_file;
};
} // device
} // pv
#endif // DSVIEW_PV_DEVICE_DEVINST_H

View File

@@ -1,129 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "file.h"
#include "inputfile.h"
#include "sessionfile.h"
#include <QFileInfo>
#include <assert.h>
#include "../utility/path.h"
#include <stdlib.h>
#include "../ZipMaker.h"
#include "../log.h"
namespace pv {
namespace device {
File::File(QString path)
:_path(path)
{
}
File::~File(){
}
QString File::format_device_title()
{
QFileInfo fi(_path);
return fi.fileName();
}
File* File::create(QString name)
{
auto f_name = path::ConvertPath(name);
if (sr_session_load(f_name.c_str()) == SR_OK) {
GSList *devlist = NULL;
sr_session_dev_list(&devlist);
sr_session_destroy();
if (devlist) {
sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
g_slist_free(devlist);
if (sdi) {
sr_dev_close(sdi);
sr_dev_clear(sdi->driver);
return new SessionFile(name);
}
}
}
return new InputFile(name);
}
QJsonArray File::get_decoders()
{
QJsonArray dec_array;
QJsonParseError error;
/* read "decoders" */
auto f_name = path::ConvertPath(_path);
ZipReader rd(f_name.c_str());
auto *data = rd.GetInnterFileData("decoders");
if (data != NULL){
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
QString jsonStr(raw_bytes.data());
QByteArray qbs = jsonStr.toUtf8();
QJsonDocument sessionDoc = QJsonDocument::fromJson(qbs, &error);
if (error.error != QJsonParseError::NoError){
QString estr = error.errorString();
dsv_err("File::get_decoders(), parse json error:\"%s\"!", estr.toUtf8().data());
}
dec_array = sessionDoc.array();
rd.ReleaseInnerFileData(data);
}
return dec_array;
}
QJsonDocument File::get_session()
{
QJsonDocument sessionDoc;
QJsonParseError error;
auto f_name = path::ConvertPath(_path);
ZipReader rd(f_name.c_str());
auto *data = rd.GetInnterFileData("session");
if (data != NULL){
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
QString jsonStr(raw_bytes.data());
QByteArray qbs = jsonStr.toUtf8();
sessionDoc = QJsonDocument::fromJson(qbs, &error);
if (error.error != QJsonParseError::NoError){
QString estr = error.errorString();
dsv_err("File::get_session(), parse json error:\"%s\"!", estr.toUtf8().data());
}
rd.ReleaseInnerFileData(data);
}
return sessionDoc;
}
} // device
} // pv

View File

@@ -1,58 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DEVICE_FILE_H
#define DSVIEW_PV_DEVICE_FILE_H
#include <QJsonArray>
#include <QJsonDocument>
#include <QFile>
#include <string.h>
#include "devinst.h"
namespace pv {
namespace device {
class File : public DevInst
{
protected:
File(QString path);
public:
~File();
static File* create(QString name);
QJsonArray get_decoders();
QJsonDocument get_session();
public:
QString format_device_title();
protected:
const QString _path;
};
} // device
} // pv
#endif // DSVIEW_PV_DEVICE_FILE_H

View File

@@ -1,139 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cassert>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "inputfile.h"
using std::string;
namespace pv {
namespace device {
InputFile::InputFile(QString path) :
File(path),
_input(NULL)
{
_is_file = true;
}
sr_dev_inst* InputFile::dev_inst()
{
assert(_input);
return _input->sdi;
}
void InputFile::use(SigSession *owner)
{
(void)owner;
assert(!_input);
// only *.dsl file is valid
// don't allow other types of file input
throw tr("Not a valid DSView data file.");
return;
}
void InputFile::release()
{
if (!_owner)
return;
assert(_input);
File::release();
sr_dev_close(_input->sdi);
sr_session_destroy();
_input = NULL;
}
sr_input_format* InputFile::determine_input_file_format(const QString filename)
{
int i;
/* If there are no input formats, return NULL right away. */
sr_input_format *const *const inputs = sr_input_list();
if (!inputs) {
g_critical("No supported input formats available.");
return NULL;
}
/* Otherwise, try to find an input module that can handle this file. */
for (i = 0; inputs[i]; i++) {
if (inputs[i]->format_match(filename.toUtf8().data()))
break;
}
/* Return NULL if no input module wanted to touch this. */
if (!inputs[i]) {
g_critical("Error: no matching input module found.");
return NULL;
}
return inputs[i];
}
sr_input* InputFile::load_input_file_format(const QString filename,
sr_input_format *format)
{
struct stat st;
sr_input *in;
if (!format && !(format =
determine_input_file_format(filename))) {
/* The exact cause was already logged. */
throw tr("Failed to load file");
}
if (stat(filename.toUtf8().data(), &st) == -1)
throw tr("Failed to load file");
/* Initialize the input module. */
if (!(in = new sr_input)) {
throw tr("Failed to allocate input module.");
}
in->format = format;
in->param = NULL;
if (in->format->init &&
in->format->init(in, filename.toUtf8().data()) != SR_OK) {
throw tr("Failed to load file");
}
return in;
}
void InputFile::start()
{
}
void InputFile::run()
{
assert(_input);
assert(_input->format);
assert(_input->format->loadfile);
_input->format->loadfile(_input, _path.toUtf8().data());
}
} // device
} // pv

View File

@@ -1,69 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DEVICE_INPUTFILE_H
#define DSVIEW_PV_DEVICE_INPUTFILE_H
#include "file.h"
#include <string>
struct sr_input;
struct sr_input_format;
namespace pv {
namespace device {
class InputFile : public File
{
public:
InputFile(QString path);
sr_dev_inst* dev_inst();
virtual void use(SigSession *owner);
virtual void release();
virtual void start();
virtual void run();
private:
/**
* Attempts to autodetect the format. Failing that
* @param filename The filename of the input file.
* @return A pointer to the 'struct sr_input_format' that should be used,
* or NULL if no input format was selected or auto-detected.
*/
static sr_input_format* determine_input_file_format(
const QString filename);
static sr_input* load_input_file_format(const QString filename,
sr_input_format *format);
private:
sr_input *_input;
};
} // device
} // pv
#endif // DSVIEW_PV_DEVICE_INPUTFILE_H

View File

@@ -1,85 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "sessionfile.h"
#include <assert.h>
#include "../utility/path.h"
namespace pv {
namespace device {
SessionFile::SessionFile(QString path) :
File(path)
{
_sdi = NULL;
_is_file = true;
}
sr_dev_inst* SessionFile::dev_inst()
{
return _sdi;
}
void SessionFile::use(SigSession *owner)
{
if (_sdi){
release_source();
}
auto f_name = path::ConvertPath(_path);
if (sr_session_load(f_name.c_str()) != SR_OK)
throw tr("Failed to open file.\n");
GSList *devlist = NULL;
sr_session_dev_list(&devlist);
if (!devlist || !devlist->data) {
if (devlist)
g_slist_free(devlist);
throw tr("Failed to start session.");
}
_sdi = (sr_dev_inst*)devlist->data;
g_slist_free(devlist);
File::use(owner);
}
void SessionFile::release()
{
release_source();
File::release();
}
void SessionFile::release_source()
{
if (_sdi != NULL)
{
sr_dev_close(_sdi);
sr_dev_clear(_sdi->driver);
sr_session_destroy();
_sdi = NULL;
}
}
} // device
} // pv

View File

@@ -1,48 +0,0 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DEVICE_SESSIONFILE_H
#define DSVIEW_PV_DEVICE_SESSIONFILE_H
#include "file.h"
namespace pv {
namespace device {
class SessionFile : public File
{
public:
SessionFile(QString path);
sr_dev_inst* dev_inst();
virtual void use(SigSession *owner);
virtual void release();
private:
void release_source();
private:
sr_dev_inst *_sdi;
};
} // device
} // pv
#endif // DSVIEW_PV_DEVICE_SESSIONFILE_H

View File

@@ -37,10 +37,11 @@ void DeviceAgent::update()
{
_dev_handle = NULL;
_dev_name = "";
_path = "";
_di = NULL;
_dev_type = 0;
ds_device_info info;
struct ds_device_full_info info;
if (ds_get_actived_device_info(&info) == SR_OK)
{
@@ -50,6 +51,10 @@ void DeviceAgent::update()
_dev_name = QString::fromLocal8Bit(info.name);
_driver_name = QString::fromLocal8Bit(info.driver_name);
if (info.path[0] != '\0'){
_path = QString::fromLocal8Bit(info.path);
}
if (is_in_history(_dev_handle) == false){
_is_new_device = true;
}

View File

@@ -49,6 +49,10 @@ public:
return _dev_name;
}
inline QString path(){
return _path;
}
inline QString driver_name(){
return _driver_name;
}
@@ -183,6 +187,7 @@ private:
int _dev_type;
QString _dev_name;
QString _driver_name;
QString _path;
bool _is_new_device;
struct sr_dev_inst *_di;
std::vector<ds_device_handle> _history_handles;

View File

@@ -30,13 +30,9 @@
#include <QSlider>
#include <list>
#include "../device/devinst.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
using namespace pv::device;
class DeviceAgent;
namespace pv {

View File

@@ -38,7 +38,6 @@
#include <QTimer>
#include <QWidget>
#include <vector>
#include "../device/devinst.h"
#include "../prop/binding/deviceoptions.h"
#include "../prop/binding/probeoptions.h"
#include "../toolbars/titlebar.h"
@@ -71,8 +70,6 @@ private:
int _index;
};
using namespace pv::device;
class DeviceAgent;
namespace pv {

View File

@@ -20,7 +20,6 @@
*/
#include "dsomeasure.h"
#include "../device/devinst.h"
#include "../sigsession.h"
#include "../view/view.h"

View File

@@ -29,8 +29,6 @@
#include <QLabel>
#include <QCheckBox>
#include "../device/devinst.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
#include "../ui/dscombobox.h"

View File

@@ -20,7 +20,6 @@
*/
#include "lissajousoptions.h"
#include "../device/devinst.h"
#include "../sigsession.h"
#include "../view/view.h"
#include "../view/lissajoustrace.h"

View File

@@ -20,7 +20,6 @@
*/
#include "mathoptions.h"
#include "../device/devinst.h"
#include "../sigsession.h"
#include "../view/view.h"
#include "../view/mathtrace.h"

View File

@@ -30,7 +30,6 @@
#include <QRadioButton>
#include <QString>
#include "../device/devinst.h"
#include "../prop/binding/deviceoptions.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"

View File

@@ -29,7 +29,6 @@
#include <QLabel>
#include <QCheckBox>
#include "../device/devinst.h"
#include "../prop/binding/deviceoptions.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"

View File

@@ -24,7 +24,6 @@
#include "../sigsession.h"
#include "../view/cursor.h"
#include "../view/view.h"
#include "../device/devinst.h"
using namespace boost;
using namespace std;

View File

@@ -32,7 +32,6 @@
#include "../sigsession.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
#include "../device/devinst.h"
namespace pv {
namespace dialogs {

View File

@@ -29,12 +29,9 @@
#include <QMovie>
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
using namespace pv::device;
class DeviceAgent;
namespace pv {

View File

@@ -21,7 +21,6 @@
#include "dsotriggerdock.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../dialogs/dsmessagebox.h"
#include "../view/dsosignal.h"

View File

@@ -31,8 +31,6 @@
#include "../view/logicsignal.h"
#include "../data/signaldata.h"
#include "../data/snapshot.h"
#include "../device/device.h"
#include "../device/file.h"
#include "../dialogs/dsdialog.h"
#include "../dialogs/dsmessagebox.h"

View File

@@ -22,7 +22,6 @@
#include "protocoldock.h"
#include "../sigsession.h"
#include "../view/decodetrace.h"
#include "../device/devinst.h"
#include "../data/decodermodel.h"
#include "../data/decoderstack.h"
#include "../dialogs/protocollist.h"

View File

@@ -28,7 +28,6 @@
#include "../dialogs/search.h"
#include "../data/snapshot.h"
#include "../data/logicsnapshot.h"
#include "../device/devinst.h"
#include "../dialogs/dsmessagebox.h"
#include <QObject>

View File

@@ -21,7 +21,6 @@
#include "triggerdock.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../dialogs/dsmessagebox.h"
#include "../view/view.h"

View File

@@ -94,6 +94,8 @@
#include "log.h"
#include "sigsession.h"
#include "deviceagent.h"
#include <stdlib.h>
#include "ZipMaker.h"
#define BASE_SESSION_VERSION 2
@@ -303,65 +305,6 @@ namespace pv
_search_dock->setWindowTitle(tr("Search..."));
}
/*
void MainWindow::update_device_list()
{
assert(_sampling_bar);
if (!selected_device->name().contains("virtual")) {
#if QT_VERSION >= 0x050400
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
#else
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
#endif
if (dir.exists()) {
QString str = dir.absolutePath() + "/";
QString lang_name = ".ses" + QString::number(app._frameOptions.language);
QString ses_name = str +
selected_device->name() +
QString::number(selected_device->dev_inst()->mode) +
lang_name + ".dsc";
on_load_session(ses_name);
}
} else {
QDir dir(GetResourceDir());
if (dir.exists()) {
QString str = dir.absolutePath() + "/";
QString ses_name = str +
selected_device->name() +
QString::number(selected_device->dev_inst()->mode) +
".dsc";
if (QFileInfo(ses_name).exists())
on_load_session(ses_name);
}
}
_trig_bar->restore_status();
//load specified file name from application startup param
if (_bFirstLoad){
QString ldFileName(AppControl::Instance()->_open_file_name.c_str());
if (ldFileName != ""){
if (QFile::exists(ldFileName)){
dsv_info("auto load file:%s", ldFileName.toUtf8().data());
on_load_file(ldFileName);
}
else{
dsv_err("file is not exists:%s", ldFileName.toUtf8().data());
MsgBox::Show(tr("Open file error!"), ldFileName, NULL);
}
}
}
}
*/
void MainWindow::on_load_file(QString file_name)
{
try
@@ -511,7 +454,6 @@ namespace pv
void MainWindow::on_protocol(bool visible)
{
_protocol_dock->setVisible(visible);
}
@@ -570,7 +512,6 @@ namespace pv
if (!fileName.isEmpty())
{
QStringList list = format.split('.').last().split(')');
QString suffix = list.first();
@@ -636,7 +577,7 @@ namespace pv
{
QJsonObject sessionObj = json.object();
/*
int mode = _device_agent->get_work_mode();
// check session file version
if (!sessionObj.contains("Version")){
@@ -654,48 +595,55 @@ namespace pv
switchLanguage(sessionObj["Language"].toInt());
}
// check device and mode
const sr_dev_inst *const sdi = _device_agent->dev_inst();
if ((!file_dev && strcmp(sdi->driver->name, sessionObj["Device"].toString().toUtf8()) != 0) ||
sdi->mode != sessionObj["DeviceMode"].toDouble()) {
// check device and mode
if ((!file_dev && strcmp(_device_agent->driver_name().toLocal8Bit().data(), sessionObj["Device"].toString().toUtf8()) != 0) ||
mode != sessionObj["DeviceMode"].toDouble()) {
MsgBox::Show(NULL, tr("Session File is not compatible with current device or mode!"), this);
return false;
}
// clear decoders
if (sdi->mode == LOGIC && !file_dev)
if (mode == LOGIC && !file_dev)
{
_protocol_widget->del_all_protocol();
}
// load device settings
GVariant *gvar_opts;
GVariant *gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_SESSIONS);
gsize num_opts;
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_SESSIONS, &gvar_opts) == SR_OK)) {
if (gvar_opts != NULL) {
const int *const options = (const int32_t *)g_variant_get_fixed_array(
gvar_opts, &num_opts, sizeof(int32_t));
for (unsigned int i = 0; i < num_opts; i++) {
const struct sr_config_info *const info =
sr_config_info_get(options[i]);
for (unsigned int i = 0; i < num_opts; i++)
{
const struct sr_config_info *const info = _device_agent->get_config_info(options[i]);
if (!sessionObj.contains(info->name))
continue;
if (info->datatype == SR_T_BOOL)
_device_agent->set_config(NULL, NULL, info->key, g_variant_new_boolean(sessionObj[info->name].toDouble()));
_device_agent->set_config(NULL, NULL, info->key
,g_variant_new_boolean(sessionObj[info->name].toDouble()));
else if (info->datatype == SR_T_UINT64)
_device_agent->set_config(NULL, NULL, info->key, g_variant_new_uint64(sessionObj[info->name].toString().toULongLong()));
_device_agent->set_config(NULL, NULL, info->key
,g_variant_new_uint64(sessionObj[info->name].toString().toULongLong()));
else if (info->datatype == SR_T_UINT8)
_device_agent->set_config(NULL, NULL, info->key, g_variant_new_byte(sessionObj[info->name].toString().toUInt()));
_device_agent->set_config(NULL, NULL, info->key
,g_variant_new_byte(sessionObj[info->name].toString().toUInt()));
else if (info->datatype == SR_T_FLOAT)
_device_agent->set_config(NULL, NULL, info->key, g_variant_new_double(sessionObj[info->name].toDouble()));
_device_agent->set_config(NULL, NULL, info->key
,g_variant_new_double(sessionObj[info->name].toDouble()));
else if (info->datatype == SR_T_CHAR)
_device_agent->set_config(NULL, NULL, info->key, g_variant_new_string(sessionObj[info->name].toString().toUtf8()));
_device_agent->set_config(NULL, NULL, info->key
,g_variant_new_string(sessionObj[info->name].toString().toUtf8()));
}
}
// load channel settings
if (file_dev && (sdi->mode == DSO)) {
for (const GSList *l = _device_agent->dev_inst()->channels; l; l = l->next) {
if (file_dev && mode == DSO) {
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
@@ -714,8 +662,9 @@ namespace pv
}
}
}
} else {
for (const GSList *l = _device_agent->dev_inst()->channels; l; l = l->next) {
}
else {
for (const GSList *l = _device_agent->get_channels(); l; l = l->next) {
sr_channel *const probe = (sr_channel*)l->data;
assert(probe);
bool isEnabled = false;
@@ -746,7 +695,7 @@ namespace pv
_session->reload();
// load signal setting
if (file_dev && (sdi->mode == DSO)) {
if (file_dev && mode == DSO) {
for(auto &s : _session->get_signals()) {
for (const QJsonValue &value : sessionObj["channel"].toArray()) {
@@ -766,7 +715,8 @@ namespace pv
}
}
}
} else {
}
else {
for(auto &s : _session->get_signals()) {
for (const QJsonValue &value : sessionObj["channel"].toArray()) {
QJsonObject obj = value.toObject();
@@ -822,7 +772,6 @@ namespace pv
if (sessionObj.contains("measure")) {
_view->get_viewstatus()->load_session(sessionObj["measure"].toArray());
}
*/
return true;
}
@@ -1364,6 +1313,124 @@ namespace pv
return false;
}
void MainWindow::check_session_file_version()
{
auto device_agent = _session->get_device();
if (device_agent->is_file() && device_agent->is_new_device()){
if (device_agent->get_work_mode() == LOGIC){
GVariant* gvar = device_agent->get_config(NULL, NULL, SR_CONF_FILE_VERSION);
if (gvar != NULL) {
int16_t version = g_variant_get_int16(gvar);
g_variant_unref(gvar);
if (version == 1) {
show_error(tr("Current loading file has an old format. "
"This will lead to a slow loading speed. "
"Please resave it after loaded."));
}
}
}
}
}
void MainWindow::load_device_config()
{
int lang = AppConfig::Instance()._frameOptions.language;
QString name = _device_agent->name();
int mode = _device_agent->get_work_mode();
if (_device_agent->is_hardware())
{
#if QT_VERSION >= 0x050400
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
#else
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
#endif
if (dir.exists())
{
QString str = dir.absolutePath() + "/";
QString lang_name = ".ses" + QString::number(lang);
QString ses_name = str +
name +
QString::number(mode) +
lang_name + ".dsc";
on_load_session(ses_name);
}
}
else
{
QDir dir(GetResourceDir());
if (dir.exists())
{
QString str = dir.absolutePath() + "/";
QString ses_name = str +
name +
QString::number(mode) +
".dsc";
if (QFileInfo(ses_name).exists())
on_load_session(ses_name);
}
}
}
QJsonDocument MainWindow::get_session_json_from_file(QString file)
{
QJsonDocument sessionDoc;
QJsonParseError error;
auto f_name = path::ConvertPath(file);
ZipReader rd(f_name.c_str());
auto *data = rd.GetInnterFileData("session");
if (data != NULL)
{
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
QString jsonStr(raw_bytes.data());
QByteArray qbs = jsonStr.toUtf8();
sessionDoc = QJsonDocument::fromJson(qbs, &error);
if (error.error != QJsonParseError::NoError)
{
QString estr = error.errorString();
dsv_err("File::get_session(), parse json error:\"%s\"!", estr.toUtf8().data());
}
rd.ReleaseInnerFileData(data);
}
return sessionDoc;
}
QJsonArray MainWindow::get_decoder_json_from_file(QString file)
{
QJsonArray dec_array;
QJsonParseError error;
/* read "decoders" */
auto f_name = path::ConvertPath(file);
ZipReader rd(f_name.c_str());
auto *data = rd.GetInnterFileData("decoders");
if (data != NULL)
{
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
QString jsonStr(raw_bytes.data());
QByteArray qbs = jsonStr.toUtf8();
QJsonDocument sessionDoc = QJsonDocument::fromJson(qbs, &error);
if (error.error != QJsonParseError::NoError)
{
QString estr = error.errorString();
dsv_err("File::get_decoders(), parse json error:\"%s\"!", estr.toUtf8().data());
}
dec_array = sessionDoc.array();
rd.ReleaseInnerFileData(data);
}
return dec_array;
}
void MainWindow::OnMessage(int msg)
{
switch (msg)
@@ -1401,12 +1468,24 @@ namespace pv
_msg->close();
_msg = NULL;
}
load_device_config();
_sampling_bar->update_device_list();
reset_all_view();
bool is_hardware = _session->get_device()->is_hardware();
_logo_bar->dsl_connected(is_hardware);
reset_all_view();
_logo_bar->dsl_connected(_session->get_device()->is_hardware());
_file_bar->update_view_status();
if (_device_agent->is_file()){
check_session_file_version();
StoreSession ss(_session);
// load decoder
bool bFlag = ss.load_decoders(_protocol_widget
,get_decoder_json_from_file(_device_agent->path()));
// load session
load_session_json(get_session_json_from_file(_device_agent->path()), true, !bFlag);
_session->start_capture(true);
}
}
break;
@@ -1421,7 +1500,9 @@ namespace pv
_view->timebase_changed();
break;
case DSV_MSG_DEVICE_MODE_CHANGED:
case DSV_MSG_DEVICE_MODE_CHANGED:
_sampling_bar->update_sample_rate_selector();
_sampling_bar->update_view_status();
_view->mode_changed();
reset_all_view();
break;

View File

@@ -71,8 +71,6 @@ class View;
namespace device{
class DevInst;
}
using namespace pv::device;
//The mainwindow,referenced by MainFrame
//TODO: create graph view,toolbar,and show device list
@@ -171,8 +169,11 @@ private:
//ISessionDataGetter
bool genSessionData(std::string &str);
bool gen_session_json(QJsonObject &sessionVar);
void check_session_file_version();
void load_device_config();
QJsonDocument get_session_json_from_file(QString file);
QJsonArray get_decoder_json_from_file(QString file);
//IMessageListener
void OnMessage(int msg);

View File

@@ -155,7 +155,7 @@ namespace pv
assert(!_is_saving);
assert(!_is_working);
struct ds_device_info *array = NULL;
struct ds_device_base_info *array = NULL;
int count = 0;
dsv_info("%s", "Set default device.");
@@ -171,7 +171,7 @@ namespace pv
return false;
}
struct ds_device_info *dev = (array + count - 1);
struct ds_device_base_info *dev = (array + count - 1);
ds_device_handle dev_handle = dev->handle;
free(array);
@@ -188,7 +188,7 @@ namespace pv
assert(!_is_saving);
assert(!_is_working);
// Release old device.
// Release the old device.
_device_agent.release();
if (_callback != NULL)
@@ -277,11 +277,11 @@ namespace pv
return false;
}
struct ds_device_info *SigSession::get_device_list(int &out_count, int &actived_index)
struct ds_device_base_info *SigSession::get_device_list(int &out_count, int &actived_index)
{
out_count = 0;
actived_index = -1;
struct ds_device_info *array = NULL;
struct ds_device_base_info *array = NULL;
if (ds_get_device_list(&array, &out_count) == SR_OK)
{
@@ -612,7 +612,7 @@ namespace pv
return;
if (_data_updated)
{
{
data_updated();
_data_updated = false;
_noData_cnt = 0;

View File

@@ -82,7 +82,6 @@ class LissajousTrace;
class MathTrace;
}
using namespace pv::device;
using namespace pv::data;
//created by MainWindow
@@ -292,7 +291,7 @@ public:
void set_map_zoom(int index);
void auto_end();
bool have_hardware_data();
struct ds_device_info* get_device_list(int &out_count, int &actived_index);
struct ds_device_base_info* get_device_list(int &out_count, int &actived_index);
void add_msg_listener(IMessageListener *ln);
void broadcast_msg(int msg);
bool switch_work_mode(int mode);

View File

@@ -38,7 +38,6 @@
#include "view/logicsignal.h"
#include "view/dsosignal.h"
#include "view/decodetrace.h"
#include "device/devinst.h"
#include "dock/protocoldock.h"
#include <QFileDialog>

View File

@@ -26,7 +26,6 @@
#include <QApplication>
#include "filebar.h"
#include "../device/devinst.h"
#include "../ui/msgbox.h"
#include "../config/appconfig.h"
#include "../utility/path.h"

View File

@@ -26,7 +26,6 @@
#include <QAbstractItemView>
#include <math.h>
#include <libusb-1.0/libusb.h>
#include "../device/devinst.h"
#include "../dialogs/deviceoptions.h"
#include "../dialogs/waitingdialog.h"
#include "../dialogs/dsmessagebox.h"
@@ -43,8 +42,6 @@ using std::max;
using std::min;
using std::string;
using namespace pv::device;
namespace pv
{
namespace toolbars
@@ -361,7 +358,7 @@ namespace pv
}
void SamplingBar::update_sample_rate_selector()
{
{
GVariant *gvar_dict, *gvar_list;
const uint64_t *elements = NULL;
gsize num_elements;
@@ -1078,7 +1075,7 @@ namespace pv
void SamplingBar::update_device_list()
{
struct ds_device_info *array = NULL;
struct ds_device_base_info *array = NULL;
int dev_count = 0;
int select_index = 0;
@@ -1093,7 +1090,7 @@ namespace pv
}
_updating_device_list = true;
struct ds_device_info *p = NULL;
struct ds_device_base_info *p = NULL;
ds_device_handle cur_dev_handle = NULL_HANDLE;
_device_selector.clear();
@@ -1140,9 +1137,15 @@ namespace pv
_mode_button.setEnabled(bEnable);
_configure_button.setEnabled(bEnable);
_device_selector.setEnabled(bEnable);
_sample_rate.setEnabled(bEnable);
_sample_count.setEnabled(bEnable);
if (_session->get_device()->get_work_mode() == DSO){
_sample_rate.setEnabled(false);
}
else{
_sample_rate.setEnabled(bEnable);
}
if (_session->is_working()){
_run_stop_button.setEnabled(_is_run_as_instant ? false : true);

View File

@@ -78,15 +78,14 @@ namespace pv
public:
SamplingBar(SigSession *session, QWidget *parent);
double hori_knob(int dir);
double commit_hori_res();
double get_hori_res();
void set_sample_rate(uint64_t sample_rate);
double hori_knob(int dir);
double get_hori_res();
void update_device_list();
void reload();
void update_view_status();
void config_device();
ds_device_handle get_next_device_handle();
void update_sample_rate_selector();
signals:
void sig_store_session_data();
@@ -95,8 +94,9 @@ namespace pv
void changeEvent(QEvent *event);
void retranslateUi();
void reStyle();
void update_sample_rate_selector();
void set_sample_rate(uint64_t sample_rate);
double commit_hori_res();
void update_sample_rate_selector_value();
void update_sample_count_selector();
void update_sample_count_selector_value();

View File

@@ -26,7 +26,6 @@
#include <QEvent>
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../dialogs/fftoptions.h"
#include "../dialogs/lissajousoptions.h"
#include "../dialogs/mathoptions.h"

View File

@@ -25,7 +25,6 @@
#include "../data/analog.h"
#include "../data/analogsnapshot.h"
#include "../view/view.h"
#include "../device/devinst.h"
#include "../dsvdef.h"
#include "../log.h"

View File

@@ -24,7 +24,6 @@
#include "ruler.h"
#include "view.h"
#include "../device/device.h"
#include <QBrush>
#include <QPainter>

View File

@@ -45,7 +45,6 @@
#include "../view/view.h"
#include "../widgets/decodergroupbox.h"
#include "../widgets/decodermenu.h"
#include "../device/devinst.h"
#include "../view/cursor.h"
#include "../toolbars/titlebar.h"
#include "../dsvdef.h"

View File

@@ -22,9 +22,7 @@
#include "devmode.h"
#include "view.h"
#include "trace.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../device/file.h"
#include "../sigsession.h"
#include <assert.h>
#include <QStyleOption>

View File

@@ -40,7 +40,6 @@
#include "groupsignal.h"
#include "decodetrace.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../dsvdef.h"

View File

@@ -29,7 +29,6 @@
#include "../data/dso.h"
#include "../data/dsosnapshot.h"
#include "../sigsession.h"
#include "../device/devinst.h"
using namespace std;

View File

@@ -28,7 +28,6 @@
#include "../data/mathstack.h"
#include "view.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../view/dsosignal.h"
#include "../dsvdef.h"

View File

@@ -26,7 +26,6 @@
#include "view.h"
#include "viewport.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "dsosignal.h"
#include "../dsvdef.h"

View File

@@ -32,7 +32,6 @@
#include "../data/dsosnapshot.h"
#include "../view/dsosignal.h"
#include "../view/viewport.h"
#include "../device/devinst.h"
#include "../data/spectrumstack.h"
#include "../dsvdef.h"

View File

@@ -24,7 +24,6 @@
#include "view.h"
#include "ruler.h"
#include "../device/device.h"
#include <QPainter>

View File

@@ -29,7 +29,6 @@
#include "trace.h"
#include "view.h"
#include "../device/devinst.h"
#include "../sigsession.h"
#include "../dsvdef.h"

View File

@@ -41,7 +41,6 @@
#include "lissajoustrace.h"
#include "analogsignal.h"
#include "../device/devinst.h"
#include "../sigsession.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"

View File

@@ -28,7 +28,6 @@
#include "logicsignal.h"
#include "analogsignal.h"
#include "spectrumtrace.h"
#include "../device/devinst.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include "../sigsession.h"

View File

@@ -31,7 +31,6 @@
#include "../view/trace.h"
#include "../sigsession.h"
#include "../device/devinst.h"
#include "../view/view.h"
#include "../view/trace.h"
#include "../dialogs/dsomeasure.h"

View File

@@ -24,7 +24,6 @@
#include "view.h"
#include "ruler.h"
#include "../device/device.h"
#include "dsosignal.h"
#include <QPainter>

View File

@@ -240,11 +240,11 @@ SR_API void ds_set_datafeed_callback(ds_datafeed_callback_t cb)
* Get the device list, if the field _handle is 0, the list visited to end.
* User need call free() to release the buffer. If the list is empty, the out_list is null.
*/
SR_API int ds_get_device_list(struct ds_device_info **out_list, int *out_count)
SR_API int ds_get_device_list(struct ds_device_base_info **out_list, int *out_count)
{
int num;
struct ds_device_info *array = NULL;
struct ds_device_info *p = NULL;
struct ds_device_base_info *array = NULL;
struct ds_device_base_info *p = NULL;
GSList *l;
struct sr_dev_inst *dev;
@@ -263,7 +263,7 @@ SR_API int ds_get_device_list(struct ds_device_info **out_list, int *out_count)
return SR_OK;
}
array = (struct ds_device_info *)malloc(sizeof(struct ds_device_info) * (num + 1));
array = (struct ds_device_info *)malloc(sizeof(struct ds_device_base_info) * (num + 1));
if (array == NULL)
{
pthread_mutex_unlock(&lib_ctx.mutext);
@@ -276,16 +276,7 @@ SR_API int ds_get_device_list(struct ds_device_info **out_list, int *out_count)
{
dev = l->data;
p->handle = dev->handle;
p->dev_type = dev->dev_type;
p->driver_name[0] = '\0';
p->di = dev;
strncpy(p->name, dev->name, sizeof(p->name) - 1);
if (dev->driver && dev->driver->name)
{
strncpy(p->driver_name, dev->driver->name, sizeof(p->driver_name) - 1);
}
p++;
}
@@ -561,10 +552,10 @@ SR_API int ds_remove_device(ds_device_handle handle)
* Get the actived device info.
* If the actived device is not exists, the handle filed will be set null.
*/
SR_API int ds_get_actived_device_info(struct ds_device_info *fill_info)
SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info)
{
struct sr_dev_inst *dev;
struct ds_device_info *p;
struct ds_device_full_info *p;
int ret;
if (fill_info == NULL)
@@ -576,6 +567,7 @@ SR_API int ds_get_actived_device_info(struct ds_device_info *fill_info)
p->handle = NULL_HANDLE;
p->name[0] = '\0';
p->path[0] = '\0';
p->driver_name[0] = '\0';
p->dev_type = DEV_TYPE_UNKOWN;
p->di = NULL;

View File

@@ -1279,10 +1279,17 @@ typedef unsigned long long ds_device_handle;
/**
* Device base info
*/
struct ds_device_info
struct ds_device_base_info
{
ds_device_handle handle;
char name[50];
};
struct ds_device_full_info
{
ds_device_handle handle;
char name[50];
char path[256]; //file path
char driver_name[20];
int dev_type; // enum sr_device_type
struct sr_dev_inst *di;
@@ -1344,7 +1351,7 @@ SR_API void ds_set_firmware_resource_dir(const char *dir);
* Get the device list, if the field _handle is 0, the list visited to end.
* User need call free() to release the buffer. If the list is empty, the out_list is null.
*/
SR_API int ds_get_device_list(struct ds_device_info** out_list, int *out_count);
SR_API int ds_get_device_list(struct ds_device_base_info** out_list, int *out_count);
/**
* Active a device.
@@ -1388,7 +1395,7 @@ SR_API const GSList *ds_get_actived_device_mode_list();
* Get the actived device info.
* If the actived device is not exists, the handle filed will be set null.
*/
SR_API int ds_get_actived_device_info(struct ds_device_info *fill_info);
SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info);
/**
* Get actived device work model. mode list:LOGIC、ANALOG、DSO

View File

@@ -71,7 +71,7 @@ struct source {
SR_PRIV struct sr_session *sr_session_new(void)
{
if (session != NULL){
sr_info("%s", "Destroy the old session.");
sr_detail("%s", "Destroy the old session.");
sr_session_destroy(); // Destory the old.
}