Commit 7112403f authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Check generation of system structure

parent 028040b1
......@@ -43,29 +43,43 @@ def parse_scene(scene, full_model=False):
if full_model:
# Generate a complete SDL system - to have everything in a single file
# (1) get system name
# (2) get all signal names from declaration in text boxes
# (3) get signal directions from the connection of the process to env
# (4) generate all the text
# (2) get signal directions from the connection of the process to env
# (3) generate all the text
processes = list(scene.processes)
system_name = unicode(processes[0]) if processes else u'OpenGEODE'
signals, routes = [], []
pr_txt = []
signals = []
to_env = []
from_env = []
pr_txt, channels, routes = [], [], []
for each in scene.texts:
# Parse text areas to retrieve signal names
# Parse text areas to retrieve signal names USELESS
pr = generate(each)
txt = '\n'.join(pr)
pr_txt.append(txt)
ast, _, _, _, _ = each.parser.parseSingleElement('text_area', txt)
signals.extend(['SIGNAL {}{};'
.format(sig['name'], ('(' + sig['type'] + ')')
if sig['type'] else '') for sig in ast.signals])
#routes = scene.CONTEXT.signalroutes
if processes:
to_env = processes[0].connection.out_sig
from_env = processes[0].connection.in_sig
if to_env or from_env:
channels = ['CHANNEL c']
routes = ['SIGNALROUTE r']
if from_env:
from_txt = 'FROM ENV TO {} WITH {};'\
.format(system_name, from_env)
channels.append(from_txt)
routes.append(from_txt)
if to_env:
to_txt = 'FROM {} TO ENV WITH {};'\
.format(system_name, to_env)
channels.append(to_txt)
routes.append(to_txt)
channels.append('ENDCHANNEL;')
routes.append('CONNECT c AND r;')
pr_data.append('SYSTEM {};'.format(system_name))
pr_data.extend(pr_txt)
pr_data.extend(signals)
#pr_data.extend(routes)
pr_data.extend(channels)
pr_data.append('BLOCK {};'.format(system_name))
#pr_data.extend(route)
pr_data.extend(routes)
for each in processes:
pr_data.extend(generate(each))
pr_data.append('ENDBLOCK;')
......
......@@ -356,10 +356,13 @@ def get_interfaces(ast, process_name):
continue
for sig_id in route['signals']:
# Copy the signal to the result dict
found, = [dict(sig) for sig in all_signals
if sig['name'] == sig_id]
found['direction'] = direction
async_signals.append(found)
try:
found, = [dict(sig) for sig in all_signals
if sig['name'] == sig_id]
found['direction'] = direction
async_signals.append(found)
except ValueError:
LOG.error('Signal {} is not declared'.format(sig_id))
return async_signals, system.procedures
......@@ -2314,6 +2317,7 @@ def text_area_content(root, ta_ast, context):
ta_ast.use_clauses.append(each.text)
ta_ast.asn1_files.append(use_cmt)
else:
print 'HIM'
warnings.append(
'Unsupported construct in text area content, type: ' +
str(child.type))
......@@ -3902,7 +3906,6 @@ def pr_file(root):
ast.asn1Modules = DV.asn1Modules
for child in systems:
LOG.debug('found SYSTEM')
system, err, warn = system_definition(child, parent=ast)
errors.extend(err)
warnings.extend(warn)
......
......@@ -275,7 +275,7 @@ content
| synonym_definition)*
-> ^(TEXTAREA_CONTENT fpar* procedure* variable_definition*
syntype_definition* newtype_definition* timer_declaration*
synonym_definition*);
signal_declaration* use_clause* synonym_definition*);
timer_declaration
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-10-23 14:32:25
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-10-24 10:10:52
import sys
from antlr3 import *
......@@ -3865,7 +3865,7 @@ class sdl92Lexer(Lexer):
_channel = DEFAULT_CHANNEL
# sdl92.g:1275:17: ( C O N S T A N T S )
# sdl92.g:1275:23: C O N S T A N T S
# sdl92.g:1275:25: C O N S T A N T S
pass
self.mC()
self.mO()
......@@ -3898,7 +3898,7 @@ class sdl92Lexer(Lexer):
_channel = DEFAULT_CHANNEL
# sdl92.g:1276:17: ( S T R U C T )
# sdl92.g:1276:23: S T R U C T
# sdl92.g:1276:25: S T R U C T
pass
self.mS()
self.mT()
......
This diff is collapsed.
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