Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
90025dc6
Commit
90025dc6
authored
Aug 21, 2015
by
Maxime Perrotin
Browse files
Set up periodic simulation mode
parent
8fd4b2b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/asn1_value_editor.py
View file @
90025dc6
...
...
@@ -99,7 +99,7 @@ some user data when role >= 32. 32 is Qt.UserRole. '''
minVal
=
index
.
data
(
MIN_RANGE
)
maxVal
=
index
.
data
(
MAX_RANGE
)
editor
.
setRange
(
minVal
,
maxVal
)
elif
asnType
==
'ENUMERATED'
or
asnType
==
'CHOICE'
:
elif
asnType
in
(
'ENUMERATED'
,
'CHOICE'
)
:
editor
=
QComboBox
(
parent
)
enumVal
=
index
.
data
(
CHOICE_LIST
)
for
val
in
enumVal
:
...
...
@@ -188,7 +188,8 @@ some user data when role >= 32. 32 is Qt.UserRole. '''
''' Set editor geometry (bigger box for string types) '''
asnType
=
index
.
data
(
ASN1TYPE
)
if
asnType
==
'STRING'
:
r
=
QRect
(
option
.
rect
.
x
(),
option
.
rect
.
y
(),
option
.
rect
.
width
(),
max
(
option
.
rect
.
height
(),
100
))
r
=
QRect
(
option
.
rect
.
x
(),
option
.
rect
.
y
(),
option
.
rect
.
width
(),
max
(
option
.
rect
.
height
(),
100
))
else
:
r
=
option
.
rect
editor
.
setGeometry
(
r
)
...
...
@@ -565,7 +566,7 @@ class asn1Editor(QTreeView):
return
''
subpath
=
self
.
dataPath
(
idx
.
parent
())
if
len
(
subpath
)
>
0
:
subpath
+=
'.'
subpath
+=
'.'
subpath
+=
idx
.
data
()
return
subpath
...
...
asn1_value_editor/gui.py
View file @
90025dc6
...
...
@@ -424,6 +424,11 @@ def gui():
button
.
clicked
.
connect
(
editor
.
loadTC
)
elif
button
.
objectName
()
==
'sendButton'
:
button
.
clicked
.
connect
(
editor
.
sendTC
)
if
dll
:
sdl
.
param_tc_editors
.
append
({
'name'
:
editor
.
objectName
(),
'editor'
:
editor
,
'send_btn'
:
button
})
# Create a thread to poll the message queue or open an UDP socket
if
msgQ
:
...
...
asn1_value_editor/sdlHandler.py
View file @
90025dc6
...
...
@@ -245,6 +245,12 @@ class sdlHandler(QObject):
self
.
checker_table
=
None
# Parameter when using automatic simulation (random/exhaustive)
self
.
sim_param
=
{
'state'
:
'manual'
,
'periodic'
:
[],
'random'
:
[]}
# self.buttons: paramless TC buttons (set when loading dll)
self
.
buttons
=
{}
# ASN.1 editors and send buttons of TC with parameters
# list of {'name': str, 'editor': asn1Editor, 'send_btn': QPushButton}
# set by gui.py
self
.
param_tc_editors
=
[]
@
property
def
active_tc
(
self
):
...
...
@@ -578,17 +584,34 @@ class sdlHandler(QObject):
def
random_step
(
self
):
''' One step of random simulation '''
print
'Simulation step'
if
self
.
sim_param
[
'state'
]
==
'random'
:
for
each
in
self
.
sim_param
[
'periodic'
]:
if
each
in
self
.
buttons
:
# paramless TC
self
.
buttons
[
each
].
click
()
else
:
# tc with a param, use the Send button
# (first, set a random value, TODO)
for
vals
in
self
.
param_tc_editors
:
if
vals
[
'name'
]
==
each
:
vals
[
'send_btn'
].
click
()
QTimer
().
singleShot
(
1000
,
self
.
random_step
)
def
random_simulation
(
self
):
''' Random simulator - read the config from the checker_table and
call TC either randomly or periodically, until the stop button is
pressed '''
print
'Random simulation'
self
.
sim_param
[
'state'
]
=
'random'
QTimer
().
singleShot
(
1000
,
self
.
random_step
)
self
.
sim_param
[
'random'
]
=
[]
self
.
sim_param
[
'periodic'
]
=
[]
for
row_nb
in
xrange
(
self
.
checker_table
.
rowCount
()):
name
=
self
.
checker_table
.
item
(
row_nb
,
0
).
text
()
cond
=
self
.
checker_table
.
cellWidget
(
row_nb
,
1
).
currentText
()
if
cond
==
'Random'
:
self
.
sim_param
[
'random'
].
append
(
name
)
elif
cond
==
'Periodic'
:
self
.
sim_param
[
'periodic'
].
append
(
name
)
self
.
random_step
()
def
stop_simulation
(
self
):
''' Stop a random or exhaustive simulation '''
...
...
@@ -771,7 +794,6 @@ class sdlHandler(QObject):
widget
=
self
.
dock_simu
.
widget
()
self
.
tc_area
=
widget
.
findChild
(
QGridLayout
,
'tc_grid'
)
# Find parameterless input signals and create buttons
self
.
buttons
=
{}
for
each
in
self
.
proc
.
input_signals
:
if
'type'
not
in
each
:
self
.
buttons
[
each
[
'name'
]]
=
QPushButton
(
each
[
'name'
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment