Commit 069edbeb authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Render statechart also with process type

parent 8de21056
......@@ -430,6 +430,9 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
input is resulting from sdl_to_statechart, it contains a tree of graphs
in case of composite states.
'''
if graphtree == None:
raise TypeError ("Statechart.py: 'render_statechart'"
" called with no graph tree")
# dot uses a 72 dpi value for converting its position coordinates
# Get actual rendering DPI from Qt view
for view in scene.views():
......
......@@ -982,8 +982,9 @@ class Block(object):
self.connections = []
# list of class Block
self.blocks = []
# list of class Process
# list of class Process / with separate process_types
self.processes = []
self.process_types = []
# list of ogAST.Procedure
self.procedures = []
# Block formal parameters - list of dict (unused)
......@@ -1042,3 +1043,6 @@ class AST(object):
self.systems = []
# List of Process
self.processes = []
# List of Process types
self.process_types = []
......@@ -4522,14 +4522,20 @@ def pr_file(root):
def find_processes(block):
''' Recursively find non-referenced processes in a system '''
try:
result = [proc for proc in block.processes
if not proc.referenced]
non_ref_processes = [proc for proc in block.processes
if not proc.referenced]
process_types = block.process_types
except AttributeError:
result = []
non_ref_processes, process_types = [], []
for nested in block.blocks:
result.extend(find_processes(nested))
return result
ast.processes.extend(find_processes(system))
add_p, add_t = find_processes(nested)
non_ref_processes.extend(add_p)
process_types.extend(add_t)
return non_ref_processes, process_types
non_ref_p, p_types = find_processes(system)
ast.processes.extend(non_ref_p)
ast.process_types.extend(p_types)
for child in processes:
# process definition at root level (can be a process type)
process, err, warn = process_definition(child, parent=ast)
......@@ -4549,6 +4555,7 @@ def pr_file(root):
process_instances.append(each)
elif each.process_type:
process_types.append(each)
ast.process_types.append(each)
for each in process_instances:
if each.instance_of_name is not None:
# Find corresponding process type definition
......
......@@ -1036,10 +1036,12 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
pr_data = unicode('\n'.join(pr_raw))
ast, _, err = ogParser.parse_pr(string=pr_data)
self.semantic_errors = True if err else False
try:
if len(ast.processes) == 1:
process_ast, = ast.processes
except ValueError:
LOG.debug('No statechart to render')
elif len(ast.process_types) == 1:
process_ast, = ast.process_types
else:
LOG.debug('No statechart to render (no process or process type)')
return None
try:
process_ast.input_signals = \
......
Markdown is supported
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