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
9a6a27b8
Commit
9a6a27b8
authored
Jan 01, 2015
by
Maxime Perrotin
Browse files
Add log of all TC sent, and prepare for undo/redo
parent
c4feb061
Changes
3
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/asn1_value_editor.py
View file @
9a6a27b8
...
...
@@ -498,6 +498,13 @@ class asn1Editor(QTreeView):
except
:
pass
@
property
def
gser
(
self
,
use_dash
=
False
):
''' Helper API function: return the GSER representation of the data '''
data
,
=
self
.
getVariable
().
values
()
raw
=
vn
.
toASN1ValueNotation
(
data
).
strip
()
return
raw
if
not
use_dash
else
raw
.
replace
(
'_'
,
'-'
)
def
sendTC
(
self
):
''' Encode and send the TC to the main TASTE binary using message queue or UDP '''
data
=
self
.
getVariable
()
...
...
asn1_value_editor/gui.py
View file @
9a6a27b8
...
...
@@ -17,6 +17,7 @@ import re
import
logging
import
optparse
import
time
from
functools
import
partial
from
ctypes
import
CDLL
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -32,6 +33,7 @@ from ColorFormatter import ColorFormatter
from
asn1_value_editor
import
asn1Editor
,
asn1Viewer
from
plotmanager
import
PlotManager
import
vn
try
:
import
speedometer
...
...
@@ -391,7 +393,8 @@ def gui():
elif
button
.
objectName
()
==
'sendButton'
:
button
.
clicked
.
connect
(
editor
.
sendTC
)
if
sdl
:
button
.
clicked
.
connect
(
sdl
.
on_event
)
button
.
clicked
.
connect
(
partial
(
sdl
.
on_event
,
tc_name
=
editor
.
objectName
(),
param
=
editor
))
# Create a thread to poll the message queue or open an UDP socket
if
msgQ
:
...
...
asn1_value_editor/sdlHandler.py
View file @
9a6a27b8
...
...
@@ -81,6 +81,8 @@ class sdlHandler(QObject):
self
.
current_sdl_state
=
None
# Handle the state of all timers ({'timerName': 'set'/'unset'})
self
.
timers
=
{}
# Keep a state graph to allow undo/redo and state exploration
self
.
state_graph
=
{}
@
property
def
dll
(
self
):
...
...
@@ -156,16 +158,16 @@ class sdlHandler(QObject):
self
.
log_area
.
addItem
(
'New state: {}'
.
format
(
state
))
@
Slot
()
def
on_event
(
self
):
def
on_event
(
self
,
tc_name
=
None
,
param
=
None
):
''' Process signals indicating that a PI was called in the shared lib:
read th
e global
variables and display them
'''
updat
e global
state, manage undo/redo, manage active buttons
'''
if
not
ASN1
:
# The dataview must have been loaded to create ASN.1 native types
return
complete_state
=
[]
for
var
,
(
sort
,
_
)
in
self
.
proc
.
variables
.
viewitems
():
# get internal variables, translate them to swig, and print them
typename
=
sort
.
ReferencedTypeName
.
replace
(
'-'
,
'_'
)
#print 'Reading variable "{}" of type "{}"'.format(var, typename)
get_size
=
getattr
(
self
.
dll
,
"{}_size"
.
format
(
var
))
get_size
.
restype
=
ctypes
.
c_uint
size
=
get_size
()
...
...
@@ -186,6 +188,12 @@ class sdlHandler(QObject):
as_pyside
=
vn
.
fromValueNotationToPySide
(
var
,
gser
)
self
.
asn1_editor
.
updateVariable
(
as_pyside
,
root
=
self
.
tree_items
[
var
])
complete_state
.
append
(
gser
)
# Add the SDL state to the current state
complete_state
.
append
(
self
.
current_sdl_state
)
# And save the current state in a graph
self
.
current_hash
=
hash
(
frozenset
(
complete_state
))
self
.
state_graph
[
self
.
current_hash
]
=
complete_state
# Check if the SDL state has changed
self
.
check_state
()
# Find the list of allowed TC based on the current state
...
...
@@ -203,6 +211,9 @@ class sdlHandler(QObject):
button
.
setEnabled
(
True
if
tc
in
allowed_tc
else
False
)
# Emit the list of allowed TC for the GUI to update other buttons
self
.
allowed_messages
.
emit
(
allowed_tc
)
if
tc_name
:
self
.
log_area
.
addItem
(
'Sent {}({})'
.
format
(
tc_name
,
param
.
gser
or
''
))
def
start_simu
(
self
):
...
...
@@ -231,7 +242,7 @@ class sdlHandler(QObject):
else
:
self
.
msc
.
emit
(
'out'
,
name
)
tc_func_ptr
()
self
.
on_event
()
self
.
on_event
(
tc_name
=
name
)
def
receive_tm
(
self
,
tm_name
):
''' Function called when a paramless TM is received '''
...
...
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