Commit 16c9af30 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Detect properly aggregations when saving

parent bd1d2018
......@@ -7,7 +7,7 @@
This module generates textual SDL code (PR format)
by parsing the graphical symbols.
Copyright (c) 2012-2014 European Space Agency
Copyright (c) 2012-2016 European Space Agency
Designed and implemented by Maxime Perrotin
......@@ -342,7 +342,7 @@ def _state(symbol, recursive=True, nextstate=True, composite=False, cpy=False,
else:
# Generate code for a nested state
result = Indent()
agg = ' AGGREGATION' if not list(symbol.nested_scene.start) else ''
agg = ' AGGREGATION' if symbol.nested_scene.is_aggregation() else ''#if not list(symbol.nested_scene.start) else ''
result.append('STATE{} {};'.format(agg, unicode(symbol).split()[0]))
result.append('SUBSTRUCTURE')
Indent.indent += 1
......
......@@ -371,6 +371,22 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
self.highlighted = {}
def is_aggregation(self):
''' Determine if the current scene is a state aggregation, i.e. if
if contains only floating states without children
'''
for each in self.visible_symb:
if each.hasParent:
return False
if not isinstance(each, State):
# At the moment do not support Text Areas
return False
if(child for child in each.childSymbols()
if isinstance(child, (Input, ContinuousSignal))):
return False
return True
@property
def visible_symb(self):
''' Return the visible items of a scene '''
......
......@@ -24,7 +24,7 @@ external;
CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */
PROCESS car;
STATE AGGREGATION nominal;
STATE nominal;
SUBSTRUCTURE
out (battery_discharged);
STATE battery;
......@@ -45,11 +45,15 @@ external;
RETURN battery_discharged;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF STATE (219, 274), (98, 35) */
/* CIF START (315, 314), (70, 35) */
START;
/* CIF NEXTSTATE (307, 364), (85, 35) */
NEXTSTATE battery;
/* CIF STATE (396, 412), (98, 35) */
STATE battery;
/* CIF CONNECT (268, 329), (0, 35) */
/* CIF CONNECT (445, 467), (0, 35) */
CONNECT battery_discharged;
/* CIF RETURN (250, 379), (35, 35) */
/* CIF RETURN (427, 517), (35, 35) */
RETURN battery_discharged;
ENDSTATE;
ENDSUBSTRUCTURE;
......@@ -57,9 +61,6 @@ external;
START;
/* CIF NEXTSTATE (140, 266), (100, 35) */
NEXTSTATE nominal;
/* CIF STATE (614, 272), (95, 35) */
STATE backup;
ENDSTATE;
/* CIF STATE (282, 264), (100, 35) */
STATE nominal;
/* CIF CONNECT (332, 319), (0, 35) */
......@@ -67,6 +68,9 @@ external;
/* CIF NEXTSTATE (284, 369), (95, 35) */
NEXTSTATE backup;
ENDSTATE;
/* CIF STATE (614, 272), (95, 35) */
STATE backup;
ENDSTATE;
ENDPROCESS car;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
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