forked from Ivasoft/DSView
demo
This commit is contained in:
@@ -116,6 +116,9 @@ namespace pv
|
||||
_is_auto_switch_device = false;
|
||||
_is_save_confirm_msg = false;
|
||||
|
||||
_demo_load_decoder = TRUE;
|
||||
_demo_auto_start = FALSE;
|
||||
|
||||
setup_ui();
|
||||
|
||||
setContextMenuPolicy(Qt::NoContextMenu);
|
||||
@@ -1674,6 +1677,11 @@ namespace pv
|
||||
break;
|
||||
|
||||
case DSV_MSG_START_COLLECT_WORK:
|
||||
/*demo下逻辑分析仪采集一次后,设置自动采集*/
|
||||
if (_device_agent->is_demo() && _device_agent->get_work_mode() == LOGIC)
|
||||
{
|
||||
_demo_auto_start = TRUE;
|
||||
}
|
||||
update_toolbar_view_status();
|
||||
_view->on_state_changed(false);
|
||||
_protocol_widget->update_view_status();
|
||||
@@ -1712,13 +1720,20 @@ namespace pv
|
||||
_session->device_event_object()->device_updated();
|
||||
|
||||
if (_device_agent->is_hardware())
|
||||
{
|
||||
/*切换到硬件设备,取消demo的自动采集*/
|
||||
_demo_auto_start = FALSE;
|
||||
_session->on_load_config_end();
|
||||
}
|
||||
|
||||
|
||||
if (_device_agent->get_work_mode() == LOGIC && _device_agent->is_file() == false)
|
||||
_view->auto_set_max_scale();
|
||||
|
||||
if (_device_agent->is_file())
|
||||
{
|
||||
/*切换到硬件设备,取消demo的自动采集(目前使用gboolean类型需要includeligsigork)*/
|
||||
_demo_auto_start = FALSE;
|
||||
check_session_file_version();
|
||||
|
||||
bool bDoneDecoder = false;
|
||||
@@ -1731,7 +1746,27 @@ namespace pv
|
||||
}
|
||||
|
||||
_session->start_capture(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (_device_agent->is_demo())
|
||||
{
|
||||
/*demo下逻辑分析仪如果信号模式不为RANDOM,导入解码器*/
|
||||
if(_device_agent->get_work_mode() == LOGIC)
|
||||
{
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_LOAD_DECODER);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
gboolean load_decoder = g_variant_get_boolean(gvar);
|
||||
if(load_decoder)
|
||||
{
|
||||
//加载解码器
|
||||
StoreSession ss(_session);
|
||||
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
|
||||
ss.load_decoders(_protocol_widget, deArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1746,10 +1781,11 @@ namespace pv
|
||||
_view->timebase_changed();
|
||||
break;
|
||||
|
||||
case DSV_MSG_DEVICE_MODE_CHANGED:
|
||||
case DSV_MSG_DEVICE_MODE_CHANGED:
|
||||
_view->mode_changed();
|
||||
reset_all_view();
|
||||
load_device_config();
|
||||
load_device_config();
|
||||
|
||||
update_toolbar_view_status();
|
||||
_sampling_bar->update_sample_rate_list();
|
||||
|
||||
@@ -1758,6 +1794,26 @@ namespace pv
|
||||
|
||||
if (_device_agent->get_work_mode() == LOGIC)
|
||||
_view->auto_set_max_scale();
|
||||
|
||||
if(_device_agent->is_demo())
|
||||
{
|
||||
/*demo下逻辑分析仪如果信号模式不为RANDOM,导入解码器*/
|
||||
_protocol_widget->del_all_protocol();
|
||||
if(_device_agent->get_work_mode() == LOGIC)
|
||||
{
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_LOAD_DECODER);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
gboolean load_decoder = g_variant_get_boolean(gvar);
|
||||
if(load_decoder)
|
||||
{
|
||||
StoreSession ss(_session);
|
||||
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
|
||||
ss.load_decoders(_protocol_widget, deArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DSV_MSG_NEW_USB_DEVICE:
|
||||
@@ -1838,9 +1894,49 @@ namespace pv
|
||||
}
|
||||
break;
|
||||
|
||||
case DSV_MSG_END_DEVICE_OPTIONS:
|
||||
break;
|
||||
case DSV_MSG_END_DEVICE_OPTIONS:
|
||||
if(_device_agent->is_demo())
|
||||
{
|
||||
/*信号模式发生修改,更新界面*/
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_DEMO_CHANGE);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
gboolean pattern_change = g_variant_get_boolean(gvar);
|
||||
if(pattern_change)
|
||||
{
|
||||
reset_all_view();
|
||||
load_device_config();
|
||||
update_toolbar_view_status();
|
||||
_device_agent->set_config(NULL,NULL,SR_CONF_DEMO_CHANGE,g_variant_new_boolean(FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
/*demo下逻辑分析仪如果信号模式不为RANDOM,导入解码器*/
|
||||
_protocol_widget->del_all_protocol();
|
||||
if(_device_agent->get_work_mode() == LOGIC)
|
||||
{
|
||||
_view->auto_set_max_scale();
|
||||
|
||||
GVariant *gvar = _device_agent->get_config(NULL,NULL,SR_CONF_LOAD_DECODER);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
gboolean load_decoder = g_variant_get_boolean(gvar);
|
||||
if(load_decoder)
|
||||
{
|
||||
StoreSession ss(_session);
|
||||
QJsonArray deArray = get_decoder_json_from_file(_device_agent->path());
|
||||
ss.load_decoders(_protocol_widget, deArray);
|
||||
}
|
||||
}
|
||||
|
||||
/*demo下逻辑分析仪执行一次采集后,切换信号模式自动采集*/
|
||||
if(_demo_auto_start)
|
||||
{
|
||||
_session->start_capture(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#include <QJsonDocument>
|
||||
#include <chrono>
|
||||
|
||||
//没有gboolean类型?
|
||||
#include "libsigrok.h"
|
||||
|
||||
class QAction;
|
||||
class QMenuBar;
|
||||
class QMenu;
|
||||
@@ -214,6 +217,8 @@ private:
|
||||
bool _is_auto_switch_device;
|
||||
high_resolution_clock::time_point _last_key_press_time;
|
||||
bool _is_save_confirm_msg;
|
||||
gboolean _demo_load_decoder;
|
||||
gboolean _demo_auto_start;
|
||||
|
||||
int _key_value;
|
||||
bool _key_vaild;
|
||||
|
||||
@@ -1950,6 +1950,31 @@ namespace pv
|
||||
switch (msg)
|
||||
{
|
||||
case DSV_MSG_DEVICE_OPTIONS_UPDATED:
|
||||
if(_device_agent.is_demo())
|
||||
{
|
||||
GVariant *gvar = _device_agent.get_config(NULL,NULL,SR_CONF_DEMO_CHANGE);
|
||||
if(gvar != NULL)
|
||||
{
|
||||
gboolean pattern_change = g_variant_get_boolean(gvar);
|
||||
if(pattern_change)
|
||||
{
|
||||
/*底层重置工作参数*/
|
||||
_device_agent.set_config(NULL,NULL,SR_CONF_DEMO_INIT,g_variant_new_boolean(TRUE));
|
||||
|
||||
_device_agent.update();
|
||||
|
||||
clear_all_decoder();
|
||||
|
||||
_capture_data->clear();
|
||||
_view_data->clear();
|
||||
_capture_data = _view_data;
|
||||
|
||||
init_signals();
|
||||
set_cur_snap_samplerate(_device_agent.get_sample_rate());
|
||||
set_cur_samplelimits(_device_agent.get_sample_limit());
|
||||
}
|
||||
}
|
||||
}
|
||||
reload();
|
||||
break;
|
||||
|
||||
@@ -2069,6 +2094,7 @@ namespace pv
|
||||
// Nonthing.
|
||||
}
|
||||
|
||||
//**
|
||||
bool SigSession::switch_work_mode(int mode)
|
||||
{
|
||||
assert(!_is_working);
|
||||
@@ -2077,6 +2103,7 @@ namespace pv
|
||||
if (cur_mode != mode)
|
||||
{
|
||||
GVariant *val = g_variant_new_int16(mode);
|
||||
/*底层重置工作参数*/
|
||||
_device_agent.set_config(NULL, NULL, SR_CONF_DEVICE_MODE, val);
|
||||
|
||||
if (cur_mode == LOGIC){
|
||||
@@ -2104,7 +2131,9 @@ namespace pv
|
||||
set_cur_samplelimits(_device_agent.get_sample_limit());
|
||||
|
||||
dsv_info("Switch work mode to:%d", mode);
|
||||
|
||||
broadcast_msg(DSV_MSG_DEVICE_MODE_CHANGED);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
BIN
DSView/res/demo/demo_eeprom.dsl
Normal file
BIN
DSView/res/demo/demo_eeprom.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_sawtooth_analog.dsl
Normal file
BIN
DSView/res/demo/demo_sawtooth_analog.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_sawtooth_dso.dsl
Normal file
BIN
DSView/res/demo/demo_sawtooth_dso.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_sine_analog.dsl
Normal file
BIN
DSView/res/demo/demo_sine_analog.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_sine_dso.dsl
Normal file
BIN
DSView/res/demo/demo_sine_dso.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_spi.dsl
Normal file
BIN
DSView/res/demo/demo_spi.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_square_analog.dsl
Normal file
BIN
DSView/res/demo/demo_square_analog.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_square_dso.dsl
Normal file
BIN
DSView/res/demo/demo_square_dso.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_triangle_analog.dsl
Normal file
BIN
DSView/res/demo/demo_triangle_analog.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_triangle_dso.dsl
Normal file
BIN
DSView/res/demo/demo_triangle_dso.dsl
Normal file
Binary file not shown.
BIN
DSView/res/demo/demo_uart.dsl
Normal file
BIN
DSView/res/demo/demo_uart.dsl
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -23,24 +23,112 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include <minizip/unzip.h>
|
||||
//原版导入方式**(channel_modes冲突)
|
||||
#include"../DSL/dsl.h"
|
||||
|
||||
/* Supported patterns which we can generate */
|
||||
/*修改*/
|
||||
|
||||
//信号模式
|
||||
enum DEMO_PATTERN {
|
||||
PATTERN_SINE = 0,
|
||||
PATTERN_SQUARE = 1,
|
||||
PATTERN_TRIANGLE = 2,
|
||||
PATTERN_SAWTOOTH = 3,
|
||||
PATTERN_RANDOM = 4,
|
||||
PATTERN_INVALID = -1,
|
||||
PATTERN_RANDOM = 0,
|
||||
PATTERN_DEFAULT = 1,
|
||||
};
|
||||
|
||||
static const char *pattern_strings[] = {
|
||||
"Sine",
|
||||
"Square",
|
||||
"Triangle",
|
||||
"Sawtooth",
|
||||
"Random",
|
||||
static char *pattern_strings_logic[100] = {"RANDOM"};
|
||||
static char *pattern_strings_dso[100] = {"RANDOM"};
|
||||
static char *pattern_strings_analog[100] = {"RANDOM"};
|
||||
static int pattern_logic_count = 1;
|
||||
static int pattern_dso_count= 1;
|
||||
static int pattern_analog_count= 1;
|
||||
|
||||
//协议采样率、总样本数列表
|
||||
static uint64_t samplerates_file[1];
|
||||
static uint64_t samplecounts_file[1];
|
||||
//定时器
|
||||
static GTimer *packet_interval = NULL;
|
||||
//首次开启
|
||||
static gboolean is_first = TRUE;
|
||||
static gboolean is_change = FALSE;
|
||||
//总共启用通道数(LOGIC会使用)
|
||||
static int enabled_probe_num;
|
||||
//包长度、包时间、总传输包长度
|
||||
static uint64_t packet_len;
|
||||
static gdouble packet_time;
|
||||
static uint64_t post_data_len;
|
||||
//文件路径
|
||||
extern char DS_RES_PATH[500];
|
||||
//示波器垂直分辨率变化
|
||||
static gboolean vdiv_change;
|
||||
//立即
|
||||
static gboolean instant = FALSE;
|
||||
//路径
|
||||
extern char DS_RES_PATH[500];
|
||||
//信号模式(起始一样)
|
||||
uint8_t cur_sample_generator;
|
||||
uint8_t pre_sample_generator;
|
||||
|
||||
struct session_packet_buffer;
|
||||
|
||||
struct session_vdev
|
||||
{
|
||||
int version;
|
||||
unzFile archive; // zip document
|
||||
int capfile; // current inner file open status
|
||||
|
||||
uint16_t samplerates_min_index;
|
||||
uint16_t samplerates_max_index;
|
||||
//逻辑分析仪随机数据
|
||||
void *logic_buf;
|
||||
uint64_t logic_buf_len;
|
||||
//数据记录仪周期数据
|
||||
void *analog_buf;
|
||||
uint64_t analog_buf_len;
|
||||
uint64_t analog_read_pos;
|
||||
//示波器周期数据
|
||||
|
||||
int cur_channel;
|
||||
int cur_block;
|
||||
int num_blocks;
|
||||
uint64_t samplerate;
|
||||
uint64_t total_samples;
|
||||
int64_t trig_time;
|
||||
uint64_t trig_pos;
|
||||
int cur_probes;
|
||||
int num_probes;
|
||||
int enabled_probes;
|
||||
uint64_t timebase;
|
||||
uint64_t max_timebase;
|
||||
uint64_t min_timebase;
|
||||
uint8_t unit_bits;
|
||||
uint32_t ref_min;
|
||||
uint32_t ref_max;
|
||||
uint8_t max_height;
|
||||
struct sr_status mstatus;
|
||||
struct session_packet_buffer *packet_buffer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define SESSION_MAX_CHANNEL_COUNT 512
|
||||
|
||||
struct session_packet_buffer
|
||||
{
|
||||
void *post_buf;
|
||||
uint64_t post_buf_len;
|
||||
uint64_t post_len;
|
||||
|
||||
uint64_t block_buf_len;
|
||||
uint64_t block_chan_read_pos;
|
||||
uint64_t block_data_len;
|
||||
void *block_bufs[SESSION_MAX_CHANNEL_COUNT];
|
||||
uint64_t block_read_positions[SESSION_MAX_CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
|
||||
/*修改*/
|
||||
|
||||
struct DEMO_caps {
|
||||
uint64_t mode_caps;
|
||||
uint64_t feature_caps;
|
||||
@@ -63,22 +151,10 @@ struct DEMO_profile {
|
||||
struct DEMO_caps dev_caps;
|
||||
};
|
||||
|
||||
static const uint64_t vdivs10to2000[] = {
|
||||
SR_mV(10),
|
||||
SR_mV(20),
|
||||
SR_mV(50),
|
||||
SR_mV(100),
|
||||
SR_mV(200),
|
||||
SR_mV(500),
|
||||
SR_V(1),
|
||||
SR_V(2),
|
||||
0,
|
||||
};
|
||||
|
||||
enum DEMO_CHANNEL_ID {
|
||||
DEMO_LOGIC100x16 = 0,
|
||||
DEMO_ANALOG10x2,
|
||||
DEMO_DSO200x2,
|
||||
DEMO_ANALOG10x2 = 1 ,
|
||||
DEMO_DSO200x2 = 2,
|
||||
};
|
||||
|
||||
struct DEMO_channels {
|
||||
@@ -227,6 +303,15 @@ static const int32_t probeOptions[] = {
|
||||
SR_CONF_PROBE_MAP_MAX,
|
||||
};
|
||||
|
||||
static const int32_t probeSessions[] = {
|
||||
SR_CONF_PROBE_COUPLING,
|
||||
SR_CONF_PROBE_VDIV,
|
||||
SR_CONF_PROBE_MAP_DEFAULT,
|
||||
SR_CONF_PROBE_MAP_UNIT,
|
||||
SR_CONF_PROBE_MAP_MIN,
|
||||
SR_CONF_PROBE_MAP_MAX,
|
||||
};
|
||||
|
||||
static const uint8_t probeCoupling[] = {
|
||||
SR_DC_COUPLING,
|
||||
SR_AC_COUPLING,
|
||||
@@ -258,8 +343,8 @@ static const struct DEMO_profile supported_Demo[] = {
|
||||
0,
|
||||
vdivs10to2000,
|
||||
0,
|
||||
DEMO_LOGIC100x16,
|
||||
PATTERN_SINE,
|
||||
DEMO_LOGIC100x16,
|
||||
PATTERN_RANDOM,
|
||||
SR_NS(500)}
|
||||
},
|
||||
|
||||
@@ -332,4 +417,62 @@ static const int ranx[] = {
|
||||
-41, 36, -8, 46, 47, -34, 28, -39, 7, -32, 38, -27, 28, -3, -8, 43, -37, -24, 6, 3,
|
||||
};
|
||||
|
||||
static int init_pattern_mode_list();
|
||||
|
||||
static int get_pattern_mode_index_by_string(uint8_t device_mode , const char* str);
|
||||
|
||||
static int scan_dsl_file(struct sr_dev_inst *sdi);
|
||||
|
||||
static char* get_dsl_path_by_pattern_mode(uint8_t device_mode ,uint8_t pattern_mode);
|
||||
|
||||
static void adjust_samplerate(struct sr_dev_inst *sdi);
|
||||
|
||||
static int init_random_data(struct session_vdev * vdev);
|
||||
|
||||
static int hw_init(struct sr_context *sr_ctx);
|
||||
|
||||
static GSList *hw_scan(GSList *options);
|
||||
|
||||
static const GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi);
|
||||
|
||||
static int hw_dev_open(struct sr_dev_inst *sdi);
|
||||
|
||||
static int hw_dev_close(struct sr_dev_inst *sdi);
|
||||
|
||||
static int dev_destroy(struct sr_dev_inst *sdi);
|
||||
|
||||
|
||||
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel *ch,
|
||||
const struct sr_channel_group *cg);
|
||||
|
||||
static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
struct sr_channel *ch,
|
||||
struct sr_channel_group *cg);
|
||||
|
||||
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel_group *cg);
|
||||
|
||||
static int hw_dev_acquisition_start(struct sr_dev_inst *sdi,
|
||||
void *cb_data);
|
||||
|
||||
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data);
|
||||
|
||||
static int hw_dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *status, gboolean prg);
|
||||
|
||||
static int load_virtual_device_session(struct sr_dev_inst *sdi);
|
||||
|
||||
static int receive_data_logic(int fd, int revents, const struct sr_dev_inst *sdi);
|
||||
|
||||
static int receive_data_logic_decoder(int fd, int revents, const struct sr_dev_inst *sdi);
|
||||
|
||||
static int receive_data_dso(int fd, int revents, const struct sr_dev_inst *sdi);
|
||||
|
||||
static int receive_data_analog(int fd, int revents, const struct sr_dev_inst *sdi);
|
||||
|
||||
static void send_error_packet(const struct sr_dev_inst *cb_sdi, struct session_vdev *vdev, struct sr_datafeed_packet *packet);
|
||||
|
||||
static int close_archive(struct session_vdev *vdev);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -647,7 +647,8 @@ SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info)
|
||||
strncpy(p->driver_name, dev->driver->name, sizeof(p->driver_name) - 1);
|
||||
}
|
||||
|
||||
if (dev->dev_type == DEV_TYPE_FILELOG && dev->path != NULL){
|
||||
//demo paht
|
||||
if ((dev->dev_type == DEV_TYPE_FILELOG || dev->dev_type == DEV_TYPE_DEMO) && dev->path != NULL){
|
||||
strncpy(p->path, dev->path, sizeof(p->path) - 1);
|
||||
}
|
||||
ret = SR_OK;
|
||||
|
||||
@@ -1033,6 +1033,13 @@ enum sr_config_option_id
|
||||
/** The device supports setting the number of data blocks. */
|
||||
SR_CONF_NUM_BLOCKS = 30104,
|
||||
|
||||
/** demo **/
|
||||
SR_CONF_LOAD_DECODER = 30105,
|
||||
|
||||
SR_CONF_DEMO_INIT = 30106,
|
||||
|
||||
SR_CONF_DEMO_CHANGE = 30107,
|
||||
|
||||
/*--- Acquisition modes ---------------------------------------------*/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user