Commit e6c12e11 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Don't propagate all inputs in aggregations

in Helper.py, the propagate_inputs function was not adequate in the case
of state aggregations
parent d2d9d246
...@@ -201,10 +201,10 @@ LD_LIBRARY_PATH=. taste-gui -l ...@@ -201,10 +201,10 @@ LD_LIBRARY_PATH=. taste-gui -l
process_level_decl = [] process_level_decl = []
# Establish the list of states (excluding START states) XXX update C backend # Establish the list of states (excluding START states) XXX update C backend
full_statelist = list(chain(aggregates.viewkeys(), full_statelist = set(chain(aggregates.viewkeys(),
(name for name in process.mapping.iterkeys() (name for name in process.mapping.iterkeys()
if not name.endswith(u'START')))) if not name.endswith(u'START'))))
reduced_statelist = [s for s in full_statelist if s not in parallel_states] reduced_statelist = {s for s in full_statelist if s not in parallel_states}
if full_statelist: if full_statelist:
process_level_decl.append(u'type States is ({});' process_level_decl.append(u'type States is ({});'
...@@ -462,6 +462,7 @@ package {process_name} is'''.format(process_name=process_name, ...@@ -462,6 +462,7 @@ package {process_name} is'''.format(process_name=process_name,
if state.endswith(u'START'): if state.endswith(u'START'):
return return
taste_template.append(u'when {state} =>'.format(state=state)) taste_template.append(u'when {state} =>'.format(state=state))
input_def = mapping[signame].get(state)
if state in aggregates.viewkeys(): if state in aggregates.viewkeys():
# State aggregation: # State aggregation:
# - find which substate manages this input # - find which substate manages this input
...@@ -483,6 +484,9 @@ package {process_name} is'''.format(process_name=process_name, ...@@ -483,6 +484,9 @@ package {process_name} is'''.format(process_name=process_name,
break break
else: else:
# Input is not managed in the state aggregation # Input is not managed in the state aggregation
if input_def:
# check if it is managed one level above
execute_transition(state)
taste_template.append('null;') taste_template.append('null;')
else: else:
execute_transition(state) execute_transition(state)
......
...@@ -227,11 +227,7 @@ def flatten(process, sep=u'_'): ...@@ -227,11 +227,7 @@ def flatten(process, sep=u'_'):
inner.statename = prefix + inner.statename inner.statename = prefix + inner.statename
update_composite_state(inner, process) update_composite_state(inner, process)
propagate_inputs(inner, process) propagate_inputs(inner, process)
try:
del process.mapping[inner.statename] del process.mapping[inner.statename]
except KeyError:
# KeyError in case of state aggregation
pass
for each in state.terminators: for each in state.terminators:
# Give prefix to terminators # Give prefix to terminators
if each.label: if each.label:
...@@ -265,6 +261,7 @@ def flatten(process, sep=u'_'): ...@@ -265,6 +261,7 @@ def flatten(process, sep=u'_'):
to exit the composite state from the outer scope) must be to exit the composite state from the outer scope) must be
processed by each of the substates. processed by each of the substates.
''' '''
if not isinstance(nested_state, ogAST.StateAggregation):
for _, val in nested_state.mapping.viewitems(): for _, val in nested_state.mapping.viewitems():
try: try:
inputlist = context.mapping[nested_state.statename] inputlist = context.mapping[nested_state.statename]
......
SYSTEM og; SYSTEM og;
/* CIF TEXT (159, 221), (356, 248) */ /* CIF TEXT (165, 217), (356, 248) */
use dv comment 'dataview-uniq.asn'; use dv comment 'dataview-uniq.asn';
signal reset_all(MyInteger); signal reset_all(MyInteger);
signal for_a; signal for_a;
signal for_b; signal for_b;
signal response; signal response;
signal exit_aggreg;
/* CIF ENDTEXT */ /* CIF ENDTEXT */
CHANNEL c CHANNEL c
FROM ENV TO og WITH reset_all, FROM ENV TO og WITH reset_all,
for_a, for_a,
for_b; for_b,
exit_aggreg;
FROM og TO ENV WITH response; FROM og TO ENV WITH response;
ENDCHANNEL; ENDCHANNEL;
BLOCK og; BLOCK og;
SIGNALROUTE r SIGNALROUTE r
FROM ENV TO og WITH reset_all, FROM ENV TO og WITH reset_all,
for_a, for_a,
for_b; for_b,
exit_aggreg;
FROM og TO ENV WITH response; FROM og TO ENV WITH response;
CONNECT c AND r; CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */ /* CIF PROCESS (225, 49), (150, 75) */
...@@ -26,28 +29,34 @@ for_b; ...@@ -26,28 +29,34 @@ for_b;
SUBSTRUCTURE SUBSTRUCTURE
STATE a; STATE a;
SUBSTRUCTURE SUBSTRUCTURE
/* CIF START (134, 57), (70, 35) */ /* CIF START (0, 57), (70, 35) */
START; START;
/* CIF PROCEDURECALL (70, 107), (198, 35) */ /* CIF PROCEDURECALL (-64, 107), (198, 35) */
CALL writeln('[a] startup'); CALL writeln('[a] startup');
/* CIF NEXTSTATE (134, 157), (70, 35) */ /* CIF NEXTSTATE (0, 157), (70, 35) */
NEXTSTATE a1; NEXTSTATE a1;
/* CIF STATE (293, 53), (70, 35) */ /* CIF STATE (453, 53), (70, 35) */
STATE a2; STATE a2;
/* CIF INPUT (289, 108), (79, 35) */ /* CIF INPUT (239, 108), (79, 35) */
INPUT for_a; INPUT for_a;
/* CIF PROCEDURECALL (209, 158), (239, 35) */ /* CIF PROCEDURECALL (159, 158), (239, 35) */
CALL writeln('[a] Going to a1'); CALL writeln('[a] Going to a1');
/* CIF NEXTSTATE (293, 208), (70, 35) */ /* CIF NEXTSTATE (243, 208), (70, 35) */
NEXTSTATE a1; NEXTSTATE a1;
/* CIF INPUT (485, 108), (106, 35) */
INPUT reset_all(x);
/* CIF PROCEDURECALL (407, 158), (260, 35) */
CALL writeln('Reset_all from substate a2');
/* CIF NEXTSTATE (503, 208), (70, 35) */
NEXTSTATE a2;
ENDSTATE; ENDSTATE;
/* CIF STATE (134, 157), (70, 35) */ /* CIF STATE (0, 157), (70, 35) */
STATE a1; STATE a1;
/* CIF INPUT (129, 212), (79, 35) */ /* CIF INPUT (-5, 212), (79, 35) */
INPUT for_a; INPUT for_a;
/* CIF PROCEDURECALL (54, 262), (229, 35) */ /* CIF PROCEDURECALL (-80, 262), (229, 35) */
CALL writeln('[a] Going to a2'); CALL writeln('[a] Going to a2');
/* CIF NEXTSTATE (133, 312), (70, 35) */ /* CIF NEXTSTATE (0, 312), (70, 35) */
NEXTSTATE a2; NEXTSTATE a2;
ENDSTATE; ENDSTATE;
ENDSUBSTRUCTURE; ENDSUBSTRUCTURE;
...@@ -85,27 +94,44 @@ for_b; ...@@ -85,27 +94,44 @@ for_b;
STATE a; STATE a;
ENDSTATE; ENDSTATE;
ENDSUBSTRUCTURE; ENDSUBSTRUCTURE;
/* CIF TEXT (522, 328), (287, 140) */ /* CIF TEXT (997, 328), (289, 140) */
-- Text area for declarations and comments -- Text area for declarations and comments
dcl x myInteger; dcl x myInteger;
/* CIF ENDTEXT */ /* CIF ENDTEXT */
/* CIF START (226, 249), (70, 35) */ /* CIF START (0, 249), (70, 35) */
START; START;
/* CIF NEXTSTATE (226, 299), (70, 35) */ /* CIF NEXTSTATE (0, 299), (70, 35) */
NEXTSTATE wait; NEXTSTATE wait;
/* CIF STATE (487, 484), (70, 35) */ /* CIF STATE (577, 469), (67, 35) */
STATE wait; STATE wait;
/* CIF INPUT (555, 524), (110, 35) */
INPUT exit_aggreg;
/* CIF PROCEDURECALL (490, 574), (241, 34) */
CALL writeln('Stop state aggregation');
/* CIF NEXTSTATE (566, 623), (87, 35) */
NEXTSTATE the_end;
ENDSTATE; ENDSTATE;
/* CIF STATE (226, 299), (70, 35) */ /* CIF STATE (0, 299), (70, 35) */
STATE wait; STATE wait;
/* CIF INPUT (207, 354), (107, 35) */ /* CIF INPUT (-19, 354), (107, 35) */
INPUT reset_all(x); INPUT reset_all(x)
/* CIF PROCEDURECALL (173, 404), (174, 35) */ /* CIF COMMENT (108, 354), (372, 40) */
CALL writeln('reset'); COMMENT 'Transition is handled by a state in the state aggregation';
/* CIF NEXTSTATE (225, 454), (70, 35) */ /* CIF PROCEDURECALL (-115, 404), (300, 35) */
CALL writeln('[ERROR] Should never be called');
/* CIF NEXTSTATE (0, 454), (70, 35) */
NEXTSTATE -; NEXTSTATE -;
ENDSTATE; ENDSTATE;
/* CIF STATE (847, 464), (87, 35) */
STATE the_end;
/* CIF INPUT (837, 519), (107, 35) */
INPUT reset_all(x);
/* CIF PROCEDURECALL (741, 569), (300, 35) */
CALL writeln('Entering again aggregation');
/* CIF NEXTSTATE (856, 619), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS og; ENDPROCESS og;
ENDBLOCK; ENDBLOCK;
ENDSYSTEM; 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