Commit 3947f0f7 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Improve SDL Event handler

parent bb4e758b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Resource object code # 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) # by: The Resource Compiler for PySide (Qt v4.8.6)
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
""" """
import os import os
import ctypes
from PySide.QtGui import QDockWidget from PySide.QtGui import QDockWidget
from PySide.QtCore import Slot, Qt from PySide.QtCore import Slot, Qt
...@@ -24,6 +25,11 @@ try: ...@@ -24,6 +25,11 @@ try:
except ImportError: except ImportError:
print 'OpenGEODE module is not available' 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): class sdlHandler(object):
''' '''
...@@ -42,11 +48,11 @@ class sdlHandler(object): ...@@ -42,11 +48,11 @@ class sdlHandler(object):
self.ast = opengeode.parse(pr_files) self.ast = opengeode.parse(pr_files)
try: try:
root_ast = self.ast[0] root_ast = self.ast[0]
proc = root_ast.processes[0] self.proc = root_ast.processes[0]
except IndexError: except IndexError:
raise IOError('SDL Handler failed to initialize') raise IOError('SDL Handler failed to initialize')
opengeode.Helper.flatten(proc) opengeode.Helper.flatten(self.proc)
graph = opengeode.Statechart.create_dot_graph(proc) graph = opengeode.Statechart.create_dot_graph(self.proc)
self.sdl_scene = opengeode.SDL_Scene('statechart') self.sdl_scene = opengeode.SDL_Scene('statechart')
self.sdl_view = opengeode.SDL_View(self.sdl_scene) self.sdl_view = opengeode.SDL_View(self.sdl_scene)
opengeode.Statechart.render_statechart(self.sdl_scene, graph) opengeode.Statechart.render_statechart(self.sdl_scene, graph)
...@@ -84,5 +90,21 @@ class sdlHandler(object): ...@@ -84,5 +90,21 @@ class sdlHandler(object):
def on_event(self): def on_event(self):
''' Process signals indicating that a PI was called in the shared lib: ''' Process signals indicating that a PI was called in the shared lib:
read the global variables and display them ''' 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!' 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)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment