Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raptor Engineering Public Development
dsview
Commits
5626a9ba
Commit
5626a9ba
authored
Jun 06, 2015
by
DreamSourceLab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add session load/store funtion
parent
e37d3aec
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
639 additions
and
101 deletions
+639
-101
DSView/CMakeLists.txt
DSView/CMakeLists.txt
+4
-0
DSView/pv/dock/dsotriggerdock.cpp
DSView/pv/dock/dsotriggerdock.cpp
+3
-3
DSView/pv/dock/triggerdock.cpp
DSView/pv/dock/triggerdock.cpp
+74
-1
DSView/pv/dock/triggerdock.h
DSView/pv/dock/triggerdock.h
+5
-1
DSView/pv/mainwindow.cpp
DSView/pv/mainwindow.cpp
+193
-3
DSView/pv/mainwindow.h
DSView/pv/mainwindow.h
+3
-0
DSView/pv/sigsession.cpp
DSView/pv/sigsession.cpp
+19
-3
DSView/pv/sigsession.h
DSView/pv/sigsession.h
+1
-0
DSView/pv/toolbars/filebar.cpp
DSView/pv/toolbars/filebar.cpp
+45
-2
DSView/pv/toolbars/filebar.h
DSView/pv/toolbars/filebar.h
+6
-0
DSView/pv/view/analogsignal.cpp
DSView/pv/view/analogsignal.cpp
+1
-1
DSView/pv/view/decodetrace.cpp
DSView/pv/view/decodetrace.cpp
+1
-1
DSView/pv/view/dsosignal.cpp
DSView/pv/view/dsosignal.cpp
+144
-27
DSView/pv/view/dsosignal.h
DSView/pv/view/dsosignal.h
+9
-1
DSView/pv/view/groupsignal.cpp
DSView/pv/view/groupsignal.cpp
+1
-1
DSView/pv/view/header.cpp
DSView/pv/view/header.cpp
+6
-6
DSView/pv/view/logicsignal.cpp
DSView/pv/view/logicsignal.cpp
+1
-1
DSView/pv/view/trace.cpp
DSView/pv/view/trace.cpp
+19
-17
DSView/pv/view/trace.h
DSView/pv/view/trace.h
+0
-3
libsigrok4DSL/hardware/DSL/dscope.c
libsigrok4DSL/hardware/DSL/dscope.c
+21
-11
libsigrok4DSL/hardware/DSL/dsl.h
libsigrok4DSL/hardware/DSL/dsl.h
+1
-0
libsigrok4DSL/hardware/DSL/dslogic.c
libsigrok4DSL/hardware/DSL/dslogic.c
+46
-13
libsigrok4DSL/hardware/demo/demo.c
libsigrok4DSL/hardware/demo/demo.c
+11
-0
libsigrok4DSL/hwdriver.c
libsigrok4DSL/hwdriver.c
+7
-5
libsigrok4DSL/libsigrok.h
libsigrok4DSL/libsigrok.h
+7
-1
libsigrok4DSL/proto.h
libsigrok4DSL/proto.h
+1
-0
libsigrok4DSL/trigger.c
libsigrok4DSL/trigger.c
+10
-0
No files found.
DSView/CMakeLists.txt
View file @
5626a9ba
...
...
@@ -357,6 +357,10 @@ install(FILES res/DSLogicPro.fw DESTINATION bin/res/)
install
(
FILES res/DSLogicPro.bin DESTINATION bin/res/
)
install
(
FILES res/DSCope.fw DESTINATION bin/res/
)
install
(
FILES res/DSCope.bin DESTINATION bin/res/
)
install
(
FILES res/DSLogic_ini.dsc DESTINATION bin/res/
)
install
(
FILES res/DSLogic_ini.dsc.bak DESTINATION bin/res/
)
install
(
FILES res/DSCope_ini.dsc DESTINATION bin/res/
)
install
(
FILES res/DSCope_ini.dsc.bak DESTINATION bin/res/
)
#===============================================================================
#= Packaging (handled by CPack)
...
...
DSView/pv/dock/dsotriggerdock.cpp
View file @
5626a9ba
...
...
@@ -138,7 +138,7 @@ void DsoTriggerDock::pos_changed(int pos)
int
ret
;
ret
=
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
SR_CONF_HORIZ_TRIGGERPOS
,
g_variant_new_
uint16
((
uint16
_t
)
pos
));
g_variant_new_
byte
((
uint8
_t
)
pos
));
if
(
!
ret
)
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"Trigger Setting Issue"
));
...
...
@@ -206,7 +206,7 @@ void DsoTriggerDock::init()
GVariant
*
gvar
=
_session
.
get_device
()
->
get_config
(
NULL
,
NULL
,
SR_CONF_HORIZ_TRIGGERPOS
);
if
(
gvar
!=
NULL
)
{
uint16_t
pos
=
g_variant_get_
uint16
(
gvar
);
uint16_t
pos
=
g_variant_get_
byte
(
gvar
);
g_variant_unref
(
gvar
);
position_slider
->
setValue
(
pos
);
}
...
...
@@ -222,7 +222,7 @@ void DsoTriggerDock::init()
gvar
=
_session
.
get_device
()
->
get_config
(
NULL
,
NULL
,
SR_CONF_TRIGGER_SLOPE
);
if
(
gvar
!=
NULL
)
{
uint8_t
slope
=
g_variant_get_
uint16
(
gvar
);
uint8_t
slope
=
g_variant_get_
byte
(
gvar
);
g_variant_unref
(
gvar
);
type_group
->
button
(
slope
)
->
setChecked
(
true
);
}
...
...
DSView/pv/dock/triggerdock.cpp
View file @
5626a9ba
...
...
@@ -300,7 +300,7 @@ void TriggerDock::adv_trigger()
if
(
stream
)
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"Trigger"
));
msg
.
setInformativeText
(
tr
(
"Stram Mode Don't Support Advanced Trigger!"
));
msg
.
setInformativeText
(
tr
(
"Str
e
am Mode Don't Support Advanced Trigger!"
));
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
...
...
@@ -522,5 +522,78 @@ void TriggerDock::init()
//position_slider->setValue(pos);
}
QJsonObject
TriggerDock
::
get_session
()
{
QJsonObject
trigSes
;
trigSes
[
"triggerMode"
]
=
adv_radioButton
->
isChecked
()
?
1
:
0
;
trigSes
[
"triggerPos"
]
=
position_slider
->
value
();
trigSes
[
"triggerStages"
]
=
stages_comboBox
->
currentIndex
();
trigSes
[
"triggerSerial"
]
=
_adv_tabWidget
->
currentIndex
();
for
(
int
i
=
0
;
i
<
stages_comboBox
->
count
();
i
++
)
{
QString
value0_str
=
"triggerValue0"
+
QString
::
number
(
i
);
QString
inv0_str
=
"triggerInv0"
+
QString
::
number
(
i
);
QString
count0_str
=
"triggerCount0"
+
QString
::
number
(
i
);
QString
value1_str
=
"triggerValue1"
+
QString
::
number
(
i
);
QString
inv1_str
=
"triggerInv1"
+
QString
::
number
(
i
);
QString
count1_str
=
"triggerCount1"
+
QString
::
number
(
i
);
QString
logic_str
=
"triggerLogic"
+
QString
::
number
(
i
);
trigSes
[
value0_str
]
=
_value0_lineEdit_list
.
at
(
i
)
->
text
();
trigSes
[
value1_str
]
=
_value1_lineEdit_list
.
at
(
i
)
->
text
();
trigSes
[
inv0_str
]
=
_inv0_comboBox_list
.
at
(
i
)
->
currentIndex
();
trigSes
[
inv1_str
]
=
_inv1_comboBox_list
.
at
(
i
)
->
currentIndex
();
trigSes
[
count0_str
]
=
_count0_spinBox_list
.
at
(
i
)
->
value
();
trigSes
[
count1_str
]
=
_count1_spinBox_list
.
at
(
i
)
->
value
();
trigSes
[
logic_str
]
=
_logic_comboBox_list
.
at
(
i
)
->
currentIndex
();
}
trigSes
[
"triggerStart"
]
=
_serial_start_lineEdit
->
text
();
trigSes
[
"triggerStop"
]
=
_serial_stop_lineEdit
->
text
();
trigSes
[
"triggerClock"
]
=
_serial_edge_lineEdit
->
text
();
trigSes
[
"triggerChannel"
]
=
_serial_data_comboBox
->
currentIndex
();
trigSes
[
"triggerData"
]
=
_serial_value_lineEdit
->
text
();
return
trigSes
;
}
void
TriggerDock
::
set_session
(
QJsonObject
ses
)
{
position_slider
->
setValue
(
ses
[
"triggerPos"
].
toDouble
());
stages_comboBox
->
setCurrentIndex
(
ses
[
"triggerStages"
].
toDouble
());
_adv_tabWidget
->
setCurrentIndex
(
ses
[
"triggerSerial"
].
toDouble
());
if
(
ses
[
"triggerMode"
].
toDouble
()
==
0
)
simple_radioButton
->
click
();
else
adv_radioButton
->
click
();
for
(
int
i
=
0
;
i
<
stages_comboBox
->
count
();
i
++
)
{
QString
value0_str
=
"triggerValue0"
+
QString
::
number
(
i
);
QString
inv0_str
=
"triggerInv0"
+
QString
::
number
(
i
);
QString
count0_str
=
"triggerCount0"
+
QString
::
number
(
i
);
QString
value1_str
=
"triggerValue1"
+
QString
::
number
(
i
);
QString
inv1_str
=
"triggerInv1"
+
QString
::
number
(
i
);
QString
count1_str
=
"triggerCount1"
+
QString
::
number
(
i
);
QString
logic_str
=
"triggerLogic"
+
QString
::
number
(
i
);
_value0_lineEdit_list
.
at
(
i
)
->
setText
(
ses
[
value0_str
].
toString
());
_value1_lineEdit_list
.
at
(
i
)
->
setText
(
ses
[
value1_str
].
toString
());
_inv0_comboBox_list
.
at
(
i
)
->
setCurrentIndex
(
ses
[
inv0_str
].
toDouble
());
_inv1_comboBox_list
.
at
(
i
)
->
setCurrentIndex
(
ses
[
inv1_str
].
toDouble
());
_count0_spinBox_list
.
at
(
i
)
->
setValue
(
ses
[
count0_str
].
toDouble
());
_count1_spinBox_list
.
at
(
i
)
->
setValue
(
ses
[
count1_str
].
toDouble
());
_logic_comboBox_list
.
at
(
i
)
->
setCurrentIndex
(
ses
[
logic_str
].
toDouble
());
}
_serial_start_lineEdit
->
setText
(
ses
[
"triggerStart"
].
toString
());
_serial_stop_lineEdit
->
setText
(
ses
[
"triggerStop"
].
toString
());
_serial_edge_lineEdit
->
setText
(
ses
[
"triggerClock"
].
toString
());
_serial_data_comboBox
->
setCurrentIndex
(
ses
[
"triggerChannel"
].
toDouble
());
_serial_value_lineEdit
->
setText
(
ses
[
"triggerData"
].
toString
());
value_changed
();
logic_changed
(
0
);
inv_changed
(
0
);
count_changed
();
}
}
// namespace dock
}
// namespace pv
DSView/pv/dock/triggerdock.h
View file @
5626a9ba
...
...
@@ -34,6 +34,7 @@
#include <QSpinBox>
#include <QGroupBox>
#include <QTableWidget>
#include <QJsonObject>
#include <QVector>
#include <QVBoxLayout>
...
...
@@ -63,9 +64,12 @@ public:
void
init
();
QJsonObject
get_session
();
void
set_session
(
QJsonObject
ses
);
signals:
p
rivate
slots
:
p
ublic
slots
:
void
simple_trigger
();
void
adv_trigger
();
void
trigger_stages_changed
(
int
index
);
...
...
DSView/pv/mainwindow.cpp
View file @
5626a9ba
...
...
@@ -146,6 +146,10 @@ void MainWindow::setup_ui()
SLOT
(
on_save
()));
connect
(
_file_bar
,
SIGNAL
(
on_screenShot
()),
this
,
SLOT
(
on_screenShot
()));
connect
(
_file_bar
,
SIGNAL
(
load_session
(
QString
)),
this
,
SLOT
(
load_session
(
QString
)));
connect
(
_file_bar
,
SIGNAL
(
store_session
(
QString
)),
this
,
SLOT
(
store_session
(
QString
)));
#ifdef ENABLE_DECODE
// protocol dock
...
...
@@ -311,10 +315,13 @@ void MainWindow::update_device_list()
errorMessage
,
infoMessage
));
}
if
(
strcmp
(
selected_device
->
dev_inst
()
->
driver
->
name
,
"demo"
)
!=
0
)
if
(
strcmp
(
selected_device
->
dev_inst
()
->
driver
->
name
,
"demo"
)
!=
0
)
{
_logo_bar
->
dsl_connected
(
true
);
else
QString
ses_name
=
config_path
+
QString
::
fromLocal8Bit
(
selected_device
->
dev_inst
()
->
driver
->
name
)
+
"_ini.dsc"
;
load_session
(
ses_name
);
}
else
{
_logo_bar
->
dsl_connected
(
false
);
}
}
void
MainWindow
::
reload
()
...
...
@@ -537,7 +544,7 @@ void MainWindow::on_save()
// Show the dialog
const
QString
file_name
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
""
,
tr
(
"DSView
Sessions
(*.dsl)"
));
this
,
tr
(
"Save File"
),
""
,
tr
(
"DSView
Data
(*.dsl)"
));
if
(
file_name
.
isEmpty
())
return
;
...
...
@@ -546,6 +553,189 @@ void MainWindow::on_save()
dlg
->
run
();
}
bool
MainWindow
::
load_session
(
QString
name
)
{
QFile
sessionFile
(
name
.
toStdString
().
c_str
());
if
(
!
sessionFile
.
open
(
QIODevice
::
ReadOnly
))
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"File Error"
));
msg
.
setInformativeText
(
tr
(
"Couldn't open session file!"
));
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
return
false
;
}
QByteArray
sessionData
=
sessionFile
.
readAll
();
QJsonDocument
sessionDoc
=
QJsonDocument
::
fromJson
(
sessionData
);
QJsonObject
sessionObj
=
sessionDoc
.
object
();
// check device and mode
const
sr_dev_inst
*
const
sdi
=
_session
.
get_device
()
->
dev_inst
();
if
(
strcmp
(
sdi
->
driver
->
name
,
sessionObj
[
"Device"
].
toString
().
toLocal8Bit
())
!=
0
||
sdi
->
mode
!=
sessionObj
[
"DeviceMode"
].
toDouble
())
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"Session Error"
));
msg
.
setInformativeText
(
tr
(
"Session File is not compatible with current device or mode!"
));
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
return
false
;
}
// load device settings
GVariant
*
gvar_opts
;
gsize
num_opts
;
if
((
sr_config_list
(
sdi
->
driver
,
sdi
,
NULL
,
SR_CONF_DEVICE_SESSIONS
,
&
gvar_opts
)
==
SR_OK
))
{
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
]);
if
(
info
->
datatype
==
SR_T_BOOL
)
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
info
->
key
,
g_variant_new_boolean
(
sessionObj
[
info
->
name
].
toDouble
()));
else
if
(
info
->
datatype
==
SR_T_UINT64
)
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
info
->
key
,
g_variant_new_uint64
(
sessionObj
[
info
->
name
].
toString
().
toULongLong
()));
else
if
(
info
->
datatype
==
SR_T_UINT8
)
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
info
->
key
,
g_variant_new_byte
(
sessionObj
[
info
->
name
].
toString
().
toUInt
()));
else
if
(
info
->
datatype
==
SR_T_FLOAT
)
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
info
->
key
,
g_variant_new_double
(
sessionObj
[
info
->
name
].
toDouble
()));
else
if
(
info
->
datatype
==
SR_T_CHAR
)
_session
.
get_device
()
->
set_config
(
NULL
,
NULL
,
info
->
key
,
g_variant_new_string
(
sessionObj
[
info
->
name
].
toString
().
toLocal8Bit
()));
}
}
_sampling_bar
->
update_record_length
();
_sampling_bar
->
update_sample_rate
();
// load channel settings
for
(
const
GSList
*
l
=
_session
.
get_device
()
->
dev_inst
()
->
channels
;
l
;
l
=
l
->
next
)
{
sr_channel
*
const
probe
=
(
sr_channel
*
)
l
->
data
;
assert
(
probe
);
bool
isEnabled
=
false
;
foreach
(
const
QJsonValue
&
value
,
sessionObj
[
"channel"
].
toArray
())
{
QJsonObject
obj
=
value
.
toObject
();
qDebug
(
"obj.index = %d"
,
obj
[
"index"
].
toDouble
());
if
((
probe
->
index
==
obj
[
"index"
].
toDouble
())
&&
(
probe
->
type
==
obj
[
"type"
].
toDouble
()))
{
isEnabled
=
true
;
probe
->
enabled
=
obj
[
"enabled"
].
toBool
();
//probe->colour = obj["colour"].toString();
probe
->
name
=
g_strdup
(
obj
[
"name"
].
toString
().
toStdString
().
c_str
());
probe
->
vdiv
=
obj
[
"vdiv"
].
toDouble
();
probe
->
coupling
=
obj
[
"coupling"
].
toDouble
();
probe
->
vfactor
=
obj
[
"vfactor"
].
toDouble
();
probe
->
trig_value
=
obj
[
"trigValue"
].
toDouble
();
//probe->zeroPos = obj["zeroPos"].toDouble();
break
;
}
}
if
(
!
isEnabled
)
probe
->
enabled
=
false
;
}
_session
.
init_signals
();
// load signal setting
BOOST_FOREACH
(
const
boost
::
shared_ptr
<
view
::
Signal
>
s
,
_session
.
get_signals
())
{
foreach
(
const
QJsonValue
&
value
,
sessionObj
[
"channel"
].
toArray
())
{
QJsonObject
obj
=
value
.
toObject
();
if
((
s
->
get_index
()
==
obj
[
"index"
].
toDouble
())
&&
(
s
->
get_type
()
==
obj
[
"type"
].
toDouble
()))
{
s
->
set_colour
(
QColor
(
obj
[
"colour"
].
toString
()));
s
->
set_trig
(
obj
[
"strigger"
].
toDouble
());
boost
::
shared_ptr
<
view
::
DsoSignal
>
dsoSig
;
if
(
dsoSig
=
dynamic_pointer_cast
<
view
::
DsoSignal
>
(
s
))
{
dsoSig
->
update_hDial
();
//dsoSig->update_vDial();
dsoSig
->
set_zeroRate
(
obj
[
"zeroPos"
].
toDouble
());
dsoSig
->
set_enable
(
obj
[
"enabled"
].
toBool
());
dsoSig
->
set_trigRate
(
obj
[
"trigValue"
].
toDouble
());
}
break
;
}
}
}
// load trigger settings
if
(
sessionObj
.
contains
(
"trigger"
))
{
_trigger_widget
->
set_session
(
sessionObj
[
"trigger"
].
toObject
());
}
on_trigger
(
false
);
}
bool
MainWindow
::
store_session
(
QString
name
)
{
QFile
sessionFile
(
name
.
toStdString
().
c_str
());
if
(
!
sessionFile
.
open
(
QIODevice
::
WriteOnly
))
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"File Error"
));
msg
.
setInformativeText
(
tr
(
"Couldn't open session file to write!"
));
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
return
false
;
}
GVariant
*
gvar_opts
;
GVariant
*
gvar
;
gsize
num_opts
;
const
sr_dev_inst
*
const
sdi
=
_session
.
get_device
()
->
dev_inst
();
QJsonObject
sessionVar
;
QJsonObject
triggerVar
;
QJsonArray
channelVar
;
sessionVar
[
"Device"
]
=
QJsonValue
::
fromVariant
(
sdi
->
driver
->
name
);
sessionVar
[
"DeviceMode"
]
=
QJsonValue
::
fromVariant
(
sdi
->
mode
);
if
((
sr_config_list
(
sdi
->
driver
,
sdi
,
NULL
,
SR_CONF_DEVICE_SESSIONS
,
&
gvar_opts
)
!=
SR_OK
))
return
false
;
/* Driver supports no device instance sessions. */
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
]);
gvar
=
_session
.
get_device
()
->
get_config
(
NULL
,
NULL
,
info
->
key
);
if
(
gvar
!=
NULL
)
{
if
(
info
->
datatype
==
SR_T_BOOL
)
sessionVar
[
info
->
name
]
=
QJsonValue
::
fromVariant
(
g_variant_get_boolean
(
gvar
));
else
if
(
info
->
datatype
==
SR_T_UINT64
)
sessionVar
[
info
->
name
]
=
QJsonValue
::
fromVariant
(
QString
::
number
(
g_variant_get_uint64
(
gvar
)));
else
if
(
info
->
datatype
==
SR_T_UINT8
)
sessionVar
[
info
->
name
]
=
QJsonValue
::
fromVariant
(
QString
::
number
(
g_variant_get_byte
(
gvar
)));
else
if
(
info
->
datatype
==
SR_T_FLOAT
)
sessionVar
[
info
->
name
]
=
QJsonValue
::
fromVariant
(
g_variant_get_double
(
gvar
));
else
if
(
info
->
datatype
==
SR_T_CHAR
)
sessionVar
[
info
->
name
]
=
QJsonValue
::
fromVariant
(
g_variant_get_string
(
gvar
,
NULL
));
g_variant_unref
(
gvar
);
}
}
BOOST_FOREACH
(
const
boost
::
shared_ptr
<
view
::
Signal
>
s
,
_session
.
get_signals
())
{
QJsonObject
s_obj
;
s_obj
[
"index"
]
=
s
->
get_index
();
s_obj
[
"type"
]
=
s
->
get_type
();
s_obj
[
"enabled"
]
=
s
->
enabled
();
s_obj
[
"name"
]
=
s
->
get_name
();
s_obj
[
"colour"
]
=
QJsonValue
::
fromVariant
(
s
->
get_colour
());
s_obj
[
"strigger"
]
=
s
->
get_trig
();
boost
::
shared_ptr
<
view
::
DsoSignal
>
dsoSig
;
if
(
dsoSig
=
dynamic_pointer_cast
<
view
::
DsoSignal
>
(
s
))
{
s_obj
[
"vdiv"
]
=
QJsonValue
::
fromVariant
(
dsoSig
->
get_vDialValue
());
s_obj
[
"vfactor"
]
=
QJsonValue
::
fromVariant
(
dsoSig
->
get_factor
());
s_obj
[
"coupling"
]
=
dsoSig
->
get_acCoupling
();
s_obj
[
"trigValue"
]
=
dsoSig
->
get_trigRate
();
s_obj
[
"zeroPos"
]
=
dsoSig
->
get_zeroRate
();
}
channelVar
.
append
(
s_obj
);
}
sessionVar
[
"channel"
]
=
channelVar
;
if
(
_session
.
get_device
()
->
dev_inst
()
->
mode
==
LOGIC
)
{
sessionVar
[
"trigger"
]
=
_trigger_widget
->
get_session
();
}
QJsonDocument
sessionDoc
(
sessionVar
);
sessionFile
.
write
(
sessionDoc
.
toJson
());
return
true
;
}
bool
MainWindow
::
eventFilter
(
QObject
*
object
,
QEvent
*
event
)
{
...
...
DSView/pv/mainwindow.h
View file @
5626a9ba
...
...
@@ -117,6 +117,9 @@ private slots:
void
on_save
();
bool
load_session
(
QString
name
);
bool
store_session
(
QString
name
);
/*
* hotplug slot function
*/
...
...
DSView/pv/sigsession.cpp
View file @
5626a9ba
...
...
@@ -56,6 +56,8 @@
#include <QMessageBox>
#include <QProgressDialog>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QtConcurrent/QtConcurrent>
#include <boost/foreach.hpp>
...
...
@@ -152,7 +154,6 @@ void SigSession::set_device(boost::shared_ptr<device::DevInst> dev_inst) throw(Q
}
}
void
SigSession
::
set_file
(
const
string
&
name
)
throw
(
QString
)
{
// Deslect the old device, because file type detection in File::create
...
...
@@ -600,7 +601,7 @@ void SigSession::add_group()
std
::
vector
<
boost
::
shared_ptr
<
view
::
Signal
>
>::
iterator
i
=
_signals
.
begin
();
while
(
i
!=
_signals
.
end
())
{
if
((
*
i
)
->
get_type
()
==
view
::
Trace
::
DS
_LOGIC
&&
(
*
i
)
->
selected
())
if
((
*
i
)
->
get_type
()
==
SR_CHANNEL
_LOGIC
&&
(
*
i
)
->
selected
())
probe_index_list
.
push_back
((
*
i
)
->
get_index
());
i
++
;
}
...
...
@@ -851,7 +852,22 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi,
void
SigSession
::
feed_in_trigger
(
const
ds_trigger_pos
&
trigger_pos
)
{
receive_trigger
(
trigger_pos
.
real_pos
);
if
(
_dev_inst
->
dev_inst
()
->
mode
!=
DSO
)
{
receive_trigger
(
trigger_pos
.
real_pos
);
}
else
{
int
probe_count
=
0
;
int
probe_en_count
=
0
;
for
(
const
GSList
*
l
=
_dev_inst
->
dev_inst
()
->
channels
;
l
;
l
=
l
->
next
)
{
const
sr_channel
*
const
probe
=
(
const
sr_channel
*
)
l
->
data
;
if
(
probe
->
type
==
SR_CHANNEL_DSO
)
{
probe_count
++
;
if
(
probe
->
enabled
)
probe_en_count
++
;
}
}
receive_trigger
(
trigger_pos
.
real_pos
*
probe_count
/
probe_en_count
);
}
}
void
SigSession
::
feed_in_logic
(
const
sr_datafeed_logic
&
logic
)
...
...
DSView/pv/sigsession.h
View file @
5626a9ba
...
...
@@ -45,6 +45,7 @@
#include <QVariant>
#include <QTimer>
#include <QtConcurrent/QtConcurrent>
#include <QJsonObject>
#include <libsigrok4DSL/libsigrok.h>
#include <libusb.h>
...
...
DSView/pv/toolbars/filebar.cpp
View file @
5626a9ba
...
...
@@ -46,6 +46,24 @@ FileBar::FileBar(SigSession &session, QWidget *parent) :
{
setMovable
(
false
);
_action_load
=
new
QAction
(
this
);
_action_load
->
setText
(
QApplication
::
translate
(
"File"
,
"&Load Session..."
,
0
));
_action_load
->
setIcon
(
QIcon
::
fromTheme
(
"file"
,
QIcon
(
":/icons/open.png"
)));
_action_load
->
setObjectName
(
QString
::
fromUtf8
(
"actionLoad"
));
_file_button
.
addAction
(
_action_load
);
connect
(
_action_load
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
on_actionLoad_triggered
()));
_action_store
=
new
QAction
(
this
);
_action_store
->
setText
(
QApplication
::
translate
(
"File"
,
"S&tore Session..."
,
0
));
_action_store
->
setIcon
(
QIcon
::
fromTheme
(
"file"
,
QIcon
(
":/icons/open.png"
)));
_action_store
->
setObjectName
(
QString
::
fromUtf8
(
"actionStore"
));
_file_button
.
addAction
(
_action_store
);
connect
(
_action_store
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
on_actionStore_triggered
()));
_action_open
=
new
QAction
(
this
);
_action_open
->
setText
(
QApplication
::
translate
(
"File"
,
"&Open..."
,
0
));
...
...
@@ -96,7 +114,7 @@ void FileBar::on_actionOpen_triggered()
// Show the dialog
const
QString
file_name
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Open File"
),
""
,
tr
(
"DSView
Sessions
(*.dsl);;All Files (*.*)"
));
"DSView
Data
(*.dsl);;All Files (*.*)"
));
if
(
!
file_name
.
isEmpty
())
load_file
(
file_name
);
}
...
...
@@ -175,7 +193,7 @@ void FileBar::on_actionSave_triggered()
}
else
{
QString
file_name
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
""
,
tr
(
"DSView
Session
(*.dsl)"
));
tr
(
"DSView
Data
(*.dsl)"
));
if
(
!
file_name
.
isEmpty
())
{
QFileInfo
f
(
file_name
);
if
(
f
.
suffix
().
compare
(
"dsl"
))
...
...
@@ -185,6 +203,31 @@ void FileBar::on_actionSave_triggered()
}
}
void
FileBar
::
on_actionLoad_triggered
()
{
// Show the dialog
const
QString
file_name
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Open Session"
),
""
,
tr
(
"DSView Session (*.dsc)"
));
if
(
!
file_name
.
isEmpty
())
load_session
(
file_name
);
}
void
FileBar
::
on_actionStore_triggered
()
{
QString
default_name
=
_session
.
get_device
()
->
dev_inst
()
->
driver
->
name
;
QString
file_name
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save Session"
),
default_name
,
tr
(
"DSView Session (*.dsc)"
));
if
(
!
file_name
.
isEmpty
())
{
QFileInfo
f
(
file_name
);
if
(
f
.
suffix
().
compare
(
"dsc"
))
file_name
.
append
(
tr
(
".dsc"
));
store_session
(
file_name
);
}
}
void
FileBar
::
on_actionCapture_triggered
()
{
on_screenShot
();
...
...
DSView/pv/toolbars/filebar.h
View file @
5626a9ba
...
...
@@ -53,8 +53,12 @@ signals:
void
load_file
(
QString
);
void
save
();
void
on_screenShot
();
void
load_session
(
QString
);
void
store_session
(
QString
);
private
slots
:
void
on_actionLoad_triggered
();
void
on_actionStore_triggered
();
void
on_actionOpen_triggered
();
void
on_actionSave_triggered
();
void
on_actionCapture_triggered
();
...
...
@@ -66,6 +70,8 @@ private:
QToolButton
_file_button
;
QAction
*
_action_load
;
QAction
*
_action_store
;
QAction
*
_action_open
;
QAction
*
_action_save
;
QAction
*
_action_export
;
...
...
DSView/pv/view/analogsignal.cpp
View file @
5626a9ba
...
...
@@ -54,7 +54,7 @@ const float AnalogSignal::EnvelopeThreshold = 256.0f;
AnalogSignal
::
AnalogSignal
(
boost
::
shared_ptr
<
pv
::
device
::
DevInst
>
dev_inst
,
boost
::
shared_ptr
<
data
::
Analog
>
data
,
const
sr_channel
*
const
probe
)
:
Signal
(
dev_inst
,
probe
,
DS
_ANALOG
),
Signal
(
dev_inst
,
probe
,
SR_CHANNEL
_ANALOG
),
_data
(
data
)
{
_colour
=
SignalColours
[
probe
->
index
%
countof
(
SignalColours
)];
...
...
DSView/pv/view/decodetrace.cpp
View file @
5626a9ba
...
...
@@ -117,7 +117,7 @@ const QColor DecodeTrace::OutlineColours[16] = {
DecodeTrace
::
DecodeTrace
(
pv
::
SigSession
&
session
,
boost
::
shared_ptr
<
pv
::
data
::
DecoderStack
>
decoder_stack
,
int
index
)
:
Trace
(
QString
::
fromUtf8
(
decoder_stack
->
stack
().
front
()
->
decoder
()
->
name
),
index
,
Trace
::
DS
_DECODER
),
decoder_stack
->
stack
().
front
()
->
decoder
()
->
name
),
index
,
SR_CHANNEL
_DECODER
),
_session
(
session
),
_decoder_stack
(
decoder_stack
),
_show_hide_mapper
(
this
),
...
...
DSView/pv/view/dsosignal.cpp
View file @
5626a9ba
...
...
@@ -112,7 +112,7 @@ const int DsoSignal::RightMargin = 30;
DsoSignal
::
DsoSignal
(
boost
::
shared_ptr
<
pv
::
device
::
DevInst
>
dev_inst
,
boost
::
shared_ptr
<
data
::
Dso
>
data
,
const
sr_channel
*
const
probe
)
:
Signal
(
dev_inst
,
probe
,
DS
_DSO
),
Signal
(
dev_inst
,
probe
,
SR_CHANNEL
_DSO
),
_data
(
data
),
_scale
(
0
),
_vDialActive
(
false
),
...
...
@@ -148,31 +148,34 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
_colour
=
SignalColours
[
probe
->
index
%
countof
(
SignalColours
)];
GVariant
*
gvar
;
gvar
=
dev_inst
->
get_config
(
probe
,
NULL
,
SR_CONF_VDIV
);
if
(
gvar
!=
NULL
)
{
_vDial
->
set_value
(
g_variant_get_uint64
(
gvar
));
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_VDIV failed."
;
}
gvar
=
dev_inst
->
get_config
(
NULL
,
NULL
,
SR_CONF_TIMEBASE
);
if
(
gvar
!=
NULL
)
{
_hDial
->
set_value
(
g_variant_get_uint64
(
gvar
));
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_TIMEBASE failed."
;
}
gvar
=
dev_inst
->
get_config
(
probe
,
NULL
,
SR_CONF_COUPLING
);
if
(
gvar
!=
NULL
)
{
_acCoupling
=
g_variant_get_byte
(
gvar
);
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_COUPLING failed."
;
}
// GVariant* gvar;
// gvar = dev_inst->get_config(probe, NULL, SR_CONF_VDIV);
// if (gvar != NULL) {
// _vDial->set_value(g_variant_get_uint64(gvar));
// g_variant_unref(gvar);
// } else {
// qDebug() << "ERROR: config_get SR_CONF_VDIV failed.";
// }
// gvar = dev_inst->get_config(NULL, NULL, SR_CONF_TIMEBASE);
// if (gvar != NULL) {
// _hDial->set_value(g_variant_get_uint64(gvar));
// g_variant_unref(gvar);
// } else {
// qDebug() << "ERROR: config_get SR_CONF_TIMEBASE failed.";
// }
// gvar = dev_inst->get_config(probe, NULL, SR_CONF_COUPLING);
// if (gvar != NULL) {
// _acCoupling = g_variant_get_byte(gvar);
// g_variant_unref(gvar);
// } else {
// qDebug() << "ERROR: config_get SR_CONF_COUPLING failed.";
// }
update_vDial
();
update_hDial
();
update_acCoupling
();
}
DsoSignal
::~
DsoSignal
()
...
...
@@ -420,6 +423,54 @@ bool DsoSignal::go_hDialNext(bool setted)
}
}
bool
DsoSignal
::
update_vDial
()
{
uint64_t
vdiv
;
//uint64_t pre_vdiv = _vDial->get_value();
GVariant
*
gvar
=
_dev_inst
->
get_config
(
_probe
,
NULL
,
SR_CONF_VDIV
);
if
(
gvar
!=
NULL
)
{
vdiv
=
g_variant_get_uint64
(
gvar
);
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_TIMEBASE failed."
;
return
false
;
}
_vDial
->
set_value
(
vdiv
);
_dev_inst
->
set_config
(
_probe
,
NULL
,
SR_CONF_VDIV
,
g_variant_new_uint64
(
_vDial
->
get_value
()));
if
(
_view
)
{
update_zeroPos
();
_view
->
set_need_update
(
true
);
_view
->
update
();
}
return
true
;
}
bool
DsoSignal
::
update_hDial
()
{
uint64_t
hdiv
;
GVariant
*
gvar
=
_dev_inst
->
get_config
(
_probe
,
NULL
,
SR_CONF_TIMEBASE
);
if
(
gvar
!=
NULL
)
{
hdiv
=
g_variant_get_uint64
(
gvar
);
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_TIMEBASE failed."
;
return
false
;
}
_hDial
->
set_value
(
hdiv
);
_dev_inst
->
set_config
(
_probe
,
NULL
,
SR_CONF_TIMEBASE
,
g_variant_new_uint64
(
_hDial
->
get_value
()));
if
(
_view
)
{
const
double
scale
=
_hDial
->
get_value
()
*
std
::
pow
(
10.0
,
-
9.0
)
*
DS_CONF_DSO_HDIVS
/
get_view_rect
().
width
();
_view
->
set_scale_offset
(
scale
,
_view
->
offset
());
_view
->
set_need_update
(
true
);
_view
->
update
();
}
return
true
;
}
uint64_t
DsoSignal
::
get_vDialValue
()
const
{
return
_vDial
->
get_value
();
...
...
@@ -454,11 +505,32 @@ void DsoSignal::set_acCoupling(uint8_t coupling)
}
}
bool
DsoSignal
::
update_acCoupling
()
{
GVariant
*
gvar
=
_dev_inst
->
get_config
(
_probe
,
NULL
,
SR_CONF_COUPLING
);
if
(
gvar
!=
NULL
)
{
_acCoupling
=
g_variant_get_byte
(
gvar
);
g_variant_unref
(
gvar
);