Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
Ocarina
Commits
e6224417
Commit
e6224417
authored
Jul 18, 2015
by
yoogx
Browse files
* Separate LMP functions in a separate package
parent
826c9659
Changes
6
Show whitespace changes
Inline
Side-by-side
doc/python.rst
View file @
e6224417
...
...
@@ -31,5 +31,11 @@ Python API description
The following lists all functions defined in the `ocarina` module
.. automodule:: ocarina
.. automodule:: ocarina.ocarina
:members:
.. automodule:: lmp
:members:
.. automodule:: ocarina_common_tools
:members:
resources/runtime/python/Makefile.am
View file @
e6224417
...
...
@@ -2,7 +2,8 @@ AUTOMAKE_OPTIONS = no-dependencies
PYTHON_FILES
=
$(srcdir)
/ocarina/ocarina.py
\
$(srcdir)
/ocarina/__init__.py
\
$(srcdir)
/ocarina/ocarina_common_tools.py
$(srcdir)
/setup.py
$(srcdir)
/ocarina/ocarina_common_tools.py
$(srcdir)
/setup.py
\
$(srcdir)
/ocarina/lmp.py
if
INSTALL_PYTHON
PYTHON_FILES
+=
\
...
...
resources/runtime/python/ocarina/lmp.py
0 → 100755
View file @
e6224417
#! /usr/bin/python
'''
:mod:`lmp`
.. moduleauthor:: Jerome Hugues, Arnaud Schach
Port of Ellidiss LMP to Ocarina Python API
'''
################################################################################
try
:
import
libocarina_python
# Ocarina bindings
import
ocarina_me_aadl_aadl_instances_nodes
as
AIN
import
ocarina_me_aadl_aadl_tree_nodes
as
ATN
from
ocarina_common_tools
import
*
import
io
except
ImportError
:
pass
################################################################################
def
getPackages
():
'''Return the list of all the packages defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPackages
)
################################################################################
def
getImportDeclarations
():
'''Return the list of all the import declarations used in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getImportDeclarations
)
################################################################################
def
getAliasDeclarations
():
'''Return the list of all the alias declaration defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getAliasDeclarations
)
################################################################################
def
getComponentTypes
(
category
):
'''Return a list of component types defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system types from the current project,
you may use the following
>>> getComponentTypes (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentTypes
,
category
)
################################################################################
def
getComponentImplementations
(
category
):
'''Return a list of component implementations defined in the
current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system implementations from the
current project, you may use the following
>>> getComponentImplementations (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentImplementations
,
category
)
################################################################################
def
getAnnexes
():
'''Return the list of all the annexes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getAnnexes
)
################################################################################
def
getPrototypes
():
'''Return the list of all the prototypes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPrototypes
)
################################################################################
def
getPrototypeBindings
():
'''Return the list of all the prototype bindings defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPrototypeBindings
)
################################################################################
def
getFlowSpecifications
():
'''Return the list of all the flow specification defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getFlowSpecifications
)
################################################################################
def
getFlowImplementations
():
'''Return the list of all the flow implementation defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getFlowImplementations
)
################################################################################
def
getModes
():
'''Return the list of all the modes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getModes
)
################################################################################
def
getModeTransitions
():
'''Return the list of all the mode transition defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getModeTransitions
)
################################################################################
def
getInModes
():
'''Return the list of all the in mode used in the current AADL project
'''
################################################################################
def
getPropertySets
():
'''Return the list of all the property set defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertySets
)
################################################################################
def
getPropertyTypes
(
propertySetId
):
'''Return the list of all the property types defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to search in
For instance, to retrieve all the property types from property
set propertySet, retrieve its id (propertySetId) and use the following
>>> getPropertyTypes (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyTypes
,
propertySetId
)
################################################################################
def
getPropertyDefinitions
(
propertySetId
):
'''Return the list of all the property declaration defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to search in
For instance, to retrieve all the property declaration from
property set propertySet, retrieve its id (propertySetId)
and use the following
>>> getPropertyDefinitions (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyDefinitions
,
propertySetId
)
################################################################################
def
getPropertyConstants
(
propertySetId
):
'''Return the list of all the constant property defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to search in
For instance, to retrieve all the constant property from property
set propertySet, retrieve its id (propertySetId) and use the following
>>> getPropertyConstants (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyConstants
,
propertySetId
)
################################################################################
def
getInstances
(
category
):
'''Return a list of instances defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system instances from the current project,
you may use the following
>>> getInstances (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getInstances
,
category
)
################################################################################
def
getComponentName
(
nodeId
):
'''Get the name of an AADL component
:param nodeId: the id of the component whose name is searched
For instance, to retrieve the name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentName (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentName
,
nodeId
)
################################################################################
def
getComponentFullname
(
nodeId
):
'''Get the full qualified name of an AADL component
:param nodeId: the id of the component whose full qualified name is searched
For instance, to retrieve the full qualified name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentFullname (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentFullname
,
nodeId
)
################################################################################
def
getInstanceName
(
nodeId
):
'''Get the name of an AADL instance
:param nodeId: the id of the instance whose name is searched
For instance, to retrieve the name of MyInstance,
retrieve its id (nodeId) and use the following
>>> getInstanceName (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getInstanceName
,
nodeId
)
################################################################################
def
getNodeId
(
name
):
'''Get the Id of a component from its name
:param name: the AADL name of the node whose id is queried
For instance, to retrieve the id of MyHome, you may use the following
>>> getNodeId (MyHome)
'''
return
runOcarinaFunction
(
libocarina_python
.
getNodeId
,
name
)
################################################################################
def
getRoot
():
'''Get the Id of the current root instantiated model
'''
return
runOcarinaFunction
(
libocarina_python
.
getRoot
)
resources/runtime/python/ocarina/ocarina.py
View file @
e6224417
...
...
@@ -92,273 +92,6 @@ def generate (generator):
################################################################################
def
getPackages
():
'''Return the list of all the packages defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPackages
)
################################################################################
def
getImportDeclarations
():
'''Return the list of all the import declarations used in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getImportDeclarations
)
################################################################################
def
getAliasDeclarations
():
'''Return the list of all the alias declaration defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getAliasDeclarations
)
################################################################################
def
getComponentTypes
(
category
):
'''Return a list of component types defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system types from the current project,
you may use the following
>>> getComponentTypes (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentTypes
,
category
)
################################################################################
def
getComponentImplementations
(
category
):
'''Return a list of component implementations defined in the
current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system implementations from the
current project, you may use the following
>>> getComponentImplementations (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentImplementations
,
category
)
################################################################################
def
getAnnexes
():
'''Return the list of all the annexes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getAnnexes
)
################################################################################
def
getPrototypes
():
'''Return the list of all the prototypes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPrototypes
)
################################################################################
def
getPrototypeBindings
():
'''Return the list of all the prototype bindings defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPrototypeBindings
)
################################################################################
def
getFlowSpecifications
():
'''Return the list of all the flow specification defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getFlowSpecifications
)
################################################################################
def
getFlowImplementations
():
'''Return the list of all the flow implementation defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getFlowImplementations
)
################################################################################
def
getModes
():
'''Return the list of all the modes defined in the current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getModes
)
################################################################################
def
getModeTransitions
():
'''Return the list of all the mode transition defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getModeTransitions
)
################################################################################
def
getInModes
():
'''Return the list of all the in mode used in the current AADL project
'''
################################################################################
def
getPropertySets
():
'''Return the list of all the property set defined in the
current AADL project
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertySets
)
################################################################################
def
getPropertyTypes
(
propertySetId
):
'''Return the list of all the property types defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to serach in
For instance, to retrieve all the property types from property
set propertySet, retrieve its id (propertySetId) and use the following
>>> getPropertyTypes (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyTypes
,
propertySetId
)
################################################################################
def
getPropertyDefinitions
(
propertySetId
):
'''Return the list of all the property declaration defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to serach in
For instance, to retrieve all the property declaration from
property set propertySet, retrieve its id (propertySetId)
and use the following
>>> getPropertyDefinitions (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyDefinitions
,
propertySetId
)
################################################################################
def
getPropertyConstants
(
propertySetId
):
'''Return the list of all the constant property defined in the
provided property set
:param propertySetId: the nodeId of the property set in the
current AADL project to serach in
For instance, to retrieve all the constant property from property
set propertySet, retrieve its id (propertySetId) and use the following
>>> getPropertyConstants (propertySetId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyConstants
,
propertySetId
)
################################################################################
def
getInstances
(
category
):
'''Return a list of instances defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system instances from the current project,
you may use the following
>>> getInstances (System)
'''
return
runOcarinaFunction
(
libocarina_python
.
getInstances
,
category
)
################################################################################
def
getComponentName
(
nodeId
):
'''Get the name of an AADL component
:param nodeId: the id of the component whose name is searched
For instance, to retrieve the name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentName (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentName
,
nodeId
)
################################################################################
def
getComponentFullname
(
nodeId
):
'''Get the full qualified name of an AADL component
:param nodeId: the id of the component whose
full qualified name is searched
For instance, to retrieve the full qualified name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentFullname (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getComponentFullname
,
nodeId
)
################################################################################
def
getInstanceName
(
nodeId
):
'''Get the name of an AADL instance
:param nodeId: the id of the instance whose name is searched
For instance, to retrieve the name of MyInstance,
retrieve its id (nodeId) and use the following
>>> getInstanceName (nodeId)
'''
return
runOcarinaFunction
(
libocarina_python
.
getInstanceName
,
nodeId
)
################################################################################
def
getNodeId
(
name
):
'''Get the Id of a component from its name
:param name: the AADL name of the node whose id is queried
For instance, to retrieve the id of MyHome, you may use the following
>>> getNodeId (MyHome)
'''
return
runOcarinaFunction
(
libocarina_python
.
getNodeId
,
name
)
################################################################################
def
getRoot
():
'''Get the Id of the current root instantiated model
'''
return
runOcarinaFunction
(
libocarina_python
.
getRoot
)
################################################################################
def
getPropertyValue
(
nodeId
,
nameId
):
'''Get the value of the property
'''
...
...
resources/runtime/python/ocarina/ocarina_common_tools.py
View file @
e6224417
#! /usr/bin/python
'''
:mod:`ocarina_common_tools` -- Tools used by Python binding
to the Ocarina AADL processor
==============================================================
:mod:`ocarina_common_tools`
.. moduleauthor:: Jerome Hugues, Arnaud Schach
This module provides tools to be used by the Python scripts
form the Python binding to the Ocarina AADL processor.
Tools used by Python binding to the Ocarina AADL processor
'''
################################################################################
...
...
@@ -28,6 +24,10 @@ except ImportError:
################################################################################
def
runOcarinaFunction
(
f
,
*
parameters
):
'''Wrapper to run an Ada function provided by Ocarina. It performs all
the redirections
'''
info
=
io
.
BytesIO
()
error
=
io
.
BytesIO
()
raisedError
=
[]
...
...
resources/runtime/python/test/metrics.py
View file @
e6224417
...
...
@@ -9,9 +9,10 @@ def printError(source, messages):
for
message
in
messages
:
print
message
def
main
(
argv
):
def
main
(
argv
):
ne
'''Test function'''
import
ocarina
;
import
lmp
;
aadlFiles
=
''
root
=
''
...
...
@@ -58,95 +59,95 @@ def main(argv):
print
'----------------------------------------------------'