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

Test instantiation

parent 04f80b2d
...@@ -350,14 +350,16 @@ LD_LIBRARY_PATH=. opengeode-simulator ...@@ -350,14 +350,16 @@ LD_LIBRARY_PATH=. opengeode-simulator
context_decl.append(u'pragma import (C, ctxt, "{}_ctxt");' context_decl.append(u'pragma import (C, ctxt, "{}_ctxt");'
.format(import_context)) .format(import_context))
if not simu: if not simu and not instance:
process_level_decl.extend(context_decl) process_level_decl.extend(context_decl)
aggreg_start_proc = []
start_transition = []
# Continuous State transition id # Continuous State transition id
if not instance:
process_level_decl.append('CS_Only : constant Integer := {};' process_level_decl.append('CS_Only : constant Integer := {};'
.format(len(process.transitions))) .format(len(process.transitions)))
for name, val in process.mapping.viewitems(): for name, val in process.mapping.viewitems():
# Test val, in principle there is a value but if the code targets # Test val, in principle there is a value but if the code targets
# generation of properties, the model may have been cleant up and # generation of properties, the model may have been cleant up and
...@@ -368,7 +370,6 @@ LD_LIBRARY_PATH=. opengeode-simulator ...@@ -368,7 +370,6 @@ LD_LIBRARY_PATH=. opengeode-simulator
# Declare start procedure for aggregate states XXX add in C generator # Declare start procedure for aggregate states XXX add in C generator
# should create one START per "via" clause, TODO later # should create one START per "via" clause, TODO later
aggreg_start_proc = []
for name, substates in aggregates.viewitems(): for name, substates in aggregates.viewitems():
proc_name = u'procedure {}{}START'.format(name, UNICODE_SEP) proc_name = u'procedure {}{}START'.format(name, UNICODE_SEP)
process_level_decl.append(u'{};'.format(proc_name)) process_level_decl.append(u'{};'.format(proc_name))
...@@ -409,7 +410,7 @@ LD_LIBRARY_PATH=. opengeode-simulator ...@@ -409,7 +410,7 @@ LD_LIBRARY_PATH=. opengeode-simulator
asn1_modules += '\nwith adaasn1rtl;\nuse adaasn1rtl;' asn1_modules += '\nwith adaasn1rtl;\nuse adaasn1rtl;'
except TypeError: except TypeError:
asn1_modules = '-- No ASN.1 data types are used in this model' asn1_modules = '-- No ASN.1 data types are used in this model'
taste_template = ['''\ taste_template = [u'''\
-- This file was generated automatically: DO NOT MODIFY IT ! -- This file was generated automatically: DO NOT MODIFY IT !
with System.IO; with System.IO;
...@@ -427,7 +428,8 @@ package body {process_name} is'''.format(process_name=process_name, ...@@ -427,7 +428,8 @@ package body {process_name} is'''.format(process_name=process_name,
dataview=asn1_modules, dataview=asn1_modules,
C='with Interfaces.C.Strings;\n' C='with Interfaces.C.Strings;\n'
'use Interfaces.C.Strings;' 'use Interfaces.C.Strings;'
if simu else '')] if simu else '') if not instance
else u"package body {} is".format(process_name)]
generic_spec, instance_decl = "", "" generic_spec, instance_decl = "", ""
if generic: if generic:
...@@ -633,6 +635,7 @@ package {process_name} is'''.format(generic=generic_spec, ...@@ -633,6 +635,7 @@ package {process_name} is'''.format(generic=generic_spec,
else: else:
taste_template.append('runTransition(CS_Only);') taste_template.append('runTransition(CS_Only);')
if not instance:
taste_template.append('case {}.state is'.format(LPREFIX)) taste_template.append('case {}.state is'.format(LPREFIX))
def case_state(state): def case_state(state):
...@@ -673,11 +676,17 @@ package {process_name} is'''.format(generic=generic_spec, ...@@ -673,11 +676,17 @@ package {process_name} is'''.format(generic=generic_spec,
else: else:
execute_transition(state) execute_transition(state)
if not instance:
map(case_state, reduced_statelist) # XXX update C generator map(case_state, reduced_statelist) # XXX update C generator
taste_template.append('when others =>') taste_template.append('when others =>')
taste_template.append('runTransition(CS_Only);') taste_template.append('runTransition(CS_Only);')
taste_template.append('end case;') taste_template.append('end case;')
else:
inst_call = u"{}_Instance.{}".format(process_name, signame)
if 'type' in signal:
inst_call += u"({})".format(param_name)
taste_template.append(inst_call + ";")
taste_template.append(u'end {};'.format(signame)) taste_template.append(u'end {};'.format(signame))
taste_template.append('\n') taste_template.append('\n')
...@@ -859,7 +868,6 @@ package {process_name} is'''.format(generic=generic_spec, ...@@ -859,7 +868,6 @@ package {process_name} is'''.format(generic=generic_spec,
if ri_inst: if ri_inst:
pkg_decl += u" ({})".format(u", ".join(ri_inst)) pkg_decl += u" ({})".format(u", ".join(ri_inst))
ads_template.append(pkg_decl + u";") ads_template.append(pkg_decl + u";")
ads_template.append(u"use {}_Instance;".format(process_name))
if simu and process.cs_mapping: if simu and process.cs_mapping:
# Callback registration for Check_Queue # Callback registration for Check_Queue
...@@ -895,7 +903,7 @@ package {process_name} is'''.format(generic=generic_spec, ...@@ -895,7 +903,7 @@ package {process_name} is'''.format(generic=generic_spec,
code_labels.extend(code_label) code_labels.extend(code_label)
# Generate the code of the runTransition procedure, if needed # Generate the code of the runTransition procedure, if needed
if process.transitions: if process.transitions and not instance:
taste_template.append('procedure runTransition(Id: Integer) is') taste_template.append('procedure runTransition(Id: Integer) is')
taste_template.append('trId : Integer := Id;') taste_template.append('trId : Integer := Id;')
if process.cs_mapping: if process.cs_mapping:
...@@ -1040,7 +1048,7 @@ package {process_name} is'''.format(generic=generic_spec, ...@@ -1040,7 +1048,7 @@ package {process_name} is'''.format(generic=generic_spec,
taste_template.append('end loop;') taste_template.append('end loop;')
taste_template.append('end runTransition;') taste_template.append('end runTransition;')
taste_template.append('\n') taste_template.append('\n')
else: elif not instance:
# No transitions defined, but keep the interface for CS_Only calls # No transitions defined, but keep the interface for CS_Only calls
taste_template.append('procedure runTransition(Id: Integer) is') taste_template.append('procedure runTransition(Id: Integer) is')
taste_template.append('begin') taste_template.append('begin')
......
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