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

Improve SDL Event handler

parent bb4e758b
......@@ -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!
......
......@@ -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)))
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