Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
3947f0f7
Commit
3947f0f7
authored
Dec 19, 2014
by
Maxime Perrotin
Browse files
Improve SDL Event handler
parent
bb4e758b
Changes
2
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/resources.py
View file @
3947f0f7
...
...
@@ -2,7 +2,7 @@
# Resource object code
#
# Created: Fri Dec 19
11:56:51
2014
# Created: Fri Dec 19
22:34:24
2014
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
...
...
asn1_value_editor/sdlHandler.py
View file @
3947f0f7
...
...
@@ -15,6 +15,7 @@
"""
import
os
import
ctypes
from
PySide.QtGui
import
QDockWidget
from
PySide.QtCore
import
Slot
,
Qt
...
...
@@ -24,6 +25,11 @@ try:
except
ImportError
:
print
'OpenGEODE module is not available'
try
:
import
dataview_uniq_asn
as
ASN1
except
ImportError
:
print
'No Python A mapper generated dataview, SDL handler cannot be used'
ASN1
=
None
class
sdlHandler
(
object
):
'''
...
...
@@ -42,11 +48,11 @@ class sdlHandler(object):
self
.
ast
=
opengeode
.
parse
(
pr_files
)
try
:
root_ast
=
self
.
ast
[
0
]
proc
=
root_ast
.
processes
[
0
]
self
.
proc
=
root_ast
.
processes
[
0
]
except
IndexError
:
raise
IOError
(
'SDL Handler failed to initialize'
)
opengeode
.
Helper
.
flatten
(
proc
)
graph
=
opengeode
.
Statechart
.
create_dot_graph
(
proc
)
opengeode
.
Helper
.
flatten
(
self
.
proc
)
graph
=
opengeode
.
Statechart
.
create_dot_graph
(
self
.
proc
)
self
.
sdl_scene
=
opengeode
.
SDL_Scene
(
'statechart'
)
self
.
sdl_view
=
opengeode
.
SDL_View
(
self
.
sdl_scene
)
opengeode
.
Statechart
.
render_statechart
(
self
.
sdl_scene
,
graph
)
...
...
@@ -84,5 +90,21 @@ class sdlHandler(object):
def
on_event
(
self
):
''' Process signals indicating that a PI was called in the shared lib:
read the global variables and display them '''
if
not
ASN1
:
# The dataview must have been loaded to create ASN.1 native types
return
print
'Event!'
for
var
,
(
sort
,
_
)
in
self
.
proc
.
variables
.
viewitems
():
# get internal variables, translate them to swig, and print them
print
'Reading variable "{}" of type "{}"'
.
format
(
var
,
sort
.
ReferencedTypeName
)
get_size
=
getattr
(
self
.
dll
,
"{}_size"
.
format
(
var
))
get_size
.
restype
=
ctypes
.
c_long
get_value
=
getattr
(
self
.
dll
,
"{}_value"
.
format
(
var
))
get_value
.
restype
=
ctypes
.
c_char_p
size
=
get_size
()
print
"size= "
,
size
#value = get_value()
#as_bytes = ctypes.cast(value,
# ctypes.POINTER((ctypes.c_byte * size)))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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