Commit e6224417 authored by yoogx's avatar yoogx

* Separate LMP functions in a separate package

parent 826c9659
......@@ -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:
......@@ -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 += \
......
#! /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)
......@@ -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
'''
......
#! /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 = []
......
......@@ -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 '----------------------------------------------------'
print 'Number of Component Instances:'
print '----------------------------------------------------'
aadlInstances=ocarina.getInstances('processor')[0]
aadlInstances=lmp.getInstances('processor')[0]
print '- Processors:\t\t',len(aadlInstances)
aadlInstances=ocarina.getInstances('process')[0]
aadlInstances=lmp.getInstances('process')[0]
print '- Processes:\t\t',len(aadlInstances)
aadlInstances=ocarina.getInstances('thread')[0]
aadlInstances=lmp.getInstances('thread')[0]
print '- Threads:\t\t',len(aadlInstances)
aadlInstances=ocarina.getInstances('subprogram')[0]
aadlInstances=lmp.getInstances('subprogram')[0]
print '- Subprograms:\t\t',len(aadlInstances)
print '----------------------------------------------------'
print ' *** DECLARATIVE MODEL ***'
print '----------------------------------------------------'
aadlPackages=ocarina.getPackages()[0]
aadlPackages=lmp.getPackages()[0]
print 'Number of Packages:\t\t\t',len(aadlPackages)
aadlCompoTypes=ocarina.getComponentTypes('all')[0]
aadlCompoTypes=lmp.getComponentTypes('all')[0]
print 'Number of Component Types:\t\t',len(aadlCompoTypes)
aadlCompoImpl=ocarina.getComponentImplementations('all')[0]
aadlCompoImpl=lmp.getComponentImplementations('all')[0]
print 'Number of Component Implementations:\t',len(aadlCompoImpl)
aadlSubcomponents=[]
for impl in aadlCompoImpl:
tmp=ocarina.ATN.Subcomponents(impl)[0]
tmp=lmp.ATN.Subcomponents(impl)[0]
if tmp is not None :
aadlSubcomponents=aadlSubcomponents+tmp
print 'Number of Subcomponents:\t\t',len(aadlSubcomponents)
aadlCalls=[]
for impl in aadlCompoImpl:
tmp=ocarina.ATN.Calls(impl)[0]
tmp=lmp.ATN.Calls(impl)[0]
if tmp is not None :
aadlCalls=aadlCalls+tmp
print 'Number of Call Sequences:\t\t',len(aadlCalls)
aadlSubprogramCalls=[]
for call in aadlCalls:
aadlSubprogramCalls=aadlSubprogramCalls+ocarina.ATN.Subprogram_Calls(call)[0]
aadlSubprogramCalls=aadlSubprogramCalls+lmp.ATN.Subprogram_Calls(call)[0]
print 'Number of Subprogram Calls:\t\t',len(aadlSubprogramCalls)
aadlFeatures=[]
for type in aadlCompoTypes:
tmp=ocarina.ATN.Features(type)[0]
tmp=lmp.ATN.Features(type)[0]
if tmp is not None :
aadlFeatures=aadlFeatures+tmp
print 'Number of Features:\t\t\t',len(aadlFeatures)
aadlConnections=[]
for impl in aadlCompoImpl:
tmp=ocarina.ATN.Connections(impl)[0]
tmp=lmp.ATN.Connections(impl)[0]
if tmp is not None :
aadlConnections=aadlConnections+tmp
print 'Number of Connections:\t\t\t',len(aadlConnections)
aadlProperties=[]
for elt in aadlCompoTypes+aadlCompoImpl+aadlFeatures+aadlConnections:
tmp=ocarina.ATN.Properties(elt)[0]
tmp=lmp.ATN.Properties(elt)[0]
if tmp is not None :
aadlProperties=aadlProperties+tmp
print 'Number of Property Associations:\t',len(aadlProperties)
print '---- Prototypes ------------------------------------'
knownAadlElt=ocarina.getPrototypes()[0]
knownAadlElt=lmp.getPrototypes()[0]
print 'Number of Prototypes:\t\t\t',len(knownAadlElt)
knownAadlElt=ocarina.getPrototypeBindings()[0]
knownAadlElt=lmp.getPrototypeBindings()[0]
print 'Number of Prototype Bindings:\t\t',len(knownAadlElt)
print '---- Flows -----------------------------------------'
knownAadlElt=ocarina.getFlowSpecifications()[0]
knownAadlElt=lmp.getFlowSpecifications()[0]
print 'Number of Flow Specifications:\t\t',len(knownAadlElt)
knownAadlElt=ocarina.getFlowImplementations()[0]
knownAadlElt=lmp.getFlowImplementations()[0]
print 'Number of Flow Implementations:\t\t',len(knownAadlElt)
print '---- Modes -----------------------------------------'
knownAadlElt=ocarina.getModes()[0]
knownAadlElt=lmp.getModes()[0]
print 'Number of Modes:\t\t\t',len(knownAadlElt)
knownAadlElt=ocarina.getModeTransitions()[0]
knownAadlElt=lmp.getModeTransitions()[0]
print 'Number of Mode Transitions:\t\t',len(knownAadlElt)
print '---- Properties ------------------------------------'
aadlPropertySets=ocarina.getPropertySets()[0]
aadlPropertySets=lmp.getPropertySets()[0]
print 'Number of Property Sets:\t\t',len(aadlPropertySets)
aadlPropertyTypes=[]
for propSet in aadlPropertySets:
tmp=ocarina.getPropertyTypes(propSet)[0]