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