Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
Ocarina
Commits
d34317cd
Commit
d34317cd
authored
Jan 20, 2015
by
yoogx
Browse files
Merge branch 'master' of
https://github.com/Ellidiss/ocarina
into Ellidiss-master
parents
0e89cc28
29994629
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
resources/runtime/python/ocarina.py
View file @
d34317cd
...
...
@@ -12,6 +12,8 @@ to load, parse, instantiate AADL models, and to invoke backends.
################################################################################
import
libocarina_python
;
# Ocarina bindings
import
ocarina_me_aadl_aadl_instances_nodes
as
AIN
;
import
ocarina_me_aadl_aadl_tree_nodes
as
ATN
;
class
Enum
(
tuple
):
__getattr__
=
tuple
.
index
...
...
@@ -81,3 +83,229 @@ def generate (generator):
################################################################################
def
getPackages
():
'''Return the list of all the packages defined in the current AADL project
'''
return
libocarina_python
.
getPackages
();
################################################################################
def
getImportDeclarations
():
'''Return the list of all the import declaration used in the current AADL project
'''
return
libocarina_python
.
getImportDeclarations
();
################################################################################
def
getAliasDeclarations
():
'''Return the list of all the alias declaration defined in the current AADL project
'''
return
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
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
libocarina_python
.
getComponentImplementations
(
category
);
################################################################################
def
getAnnexes
():
'''Return the list of all the annexes defined in the current AADL project
'''
return
libocarina_python
.
getAnnexes
();
################################################################################
def
getPrototypes
():
'''Return the list of all the prototypes defined in the current AADL project
'''
return
libocarina_python
.
getPrototypes
();
################################################################################
def
getPrototypeBindings
():
'''Return the list of all the prototype bindings defined in the current AADL project
'''
return
libocarina_python
.
getPrototypeBindings
();
################################################################################
def
getFlowSpecifications
():
'''Return the list of all the flow specification defined in the current AADL project
'''
return
libocarina_python
.
getFlowSpecifications
();
################################################################################
def
getFlowImplementations
():
'''Return the list of all the flow implementation defined in the current AADL project
'''
return
libocarina_python
.
getFlowImplementations
();
################################################################################
def
getModes
():
'''Return the list of all the modes defined in the current AADL project
'''
return
libocarina_python
.
getModes
();
################################################################################
def
getModeTransitions
():
'''Return the list of all the mode transition defined in the current AADL project
'''
return
libocarina_python
.
getModeTransitions
();
################################################################################
def
getInModes
():
'''Return the list of all the in mode used in the current AADL project
'''
return
libocarina_python
.
getInModes
();
################################################################################
def
getPropertySets
():
'''Return the list of all the property set defined in the current AADL project
'''
return
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
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
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
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
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
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
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
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
libocarina_python
.
getNodeId
(
name
);
src/python/ocarina-lmp.adb
0 → 100644
View file @
d34317cd
This diff is collapsed.
Click to expand it.
src/python/ocarina-lmp.ads
0 → 100644
View file @
d34317cd
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . L M P --
-- --
-- S p e c --
-- --
-- Copyright (C) 2013 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. Ocarina is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
pragma
Warnings
(
Off
);
with
Ocarina
.
Types
;
use
Ocarina
.
Types
;
with
GNATCOLL
.
Scripts
;
use
GNATCOLL
.
Scripts
;
with
Ocarina
.
ME_AADL
;
with
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
;
package
Ocarina
.
Lmp
is
function
Get_Packages
return
Node_List
;
function
Get_Import_Declarations
return
Node_List
;
function
Get_Alias_Declarations
return
Node_List
;
function
Get_Component_Types
(
kind
:
String
)
return
Node_List
;
function
Get_Component_Implementations
(
kind
:
String
)
return
Node_List
;
function
Get_Annexes
return
Node_List
;
function
Get_Prototype
return
Node_List
;
function
Get_Prototype_Binding
return
Node_List
;
function
Get_Flow_Specs
return
Node_List
;
function
Get_Flow_Implementations
return
Node_List
;
function
Get_Modes
return
Node_List
;
function
Get_Mode_Transitions
return
Node_List
;
function
Get_In_Modes
return
Node_List
;
-- function Get_PropertyBinding return Node_List;
function
Get_Property_Sets
return
Node_List
;
function
Get_Property_Types
(
PropertySet
:
Node_Id
)
return
Node_List
;
function
Get_Property_Definitions
(
PropertySet
:
Node_Id
)
return
Node_List
;
function
Get_Property_Constants
(
PropertySet
:
Node_Id
)
return
Node_List
;
function
Get_Instances
(
kind
:
String
)
return
Node_List
;
function
Filter_Component_By_Category
(
components
:
Node_List
;
category
:
Ocarina
.
ME_AADL
.
Component_Category
)
return
Node_List
;
function
Filter_Node_By_Kind
(
components
:
List_Id
;
category
:
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
.
Node_Kind
)
return
Node_List
;
function
Filter_Instance_By_Category
(
components
:
Node_List
;
category
:
Ocarina
.
ME_AADL
.
Component_Category
)
return
Node_List
;
procedure
Get_Component_Name
(
Data
:
in
out
Callback_Data
'
Class
;
N
:
Node_Id
);
procedure
Get_Component_Fullname
(
Data
:
in
out
Callback_Data
'
Class
;
N
:
Node_Id
);
procedure
Get_Instance_Name
(
Data
:
in
out
Callback_Data
'
Class
;
N
:
Node_Id
);
function
Find_All_Component_Implementations
(
Root
:
Node_Id
;
Namespace
:
Node_Id
:=
No_Node
)
return
Node_List
;
function
Find_All_Component_Instances
(
Root
:
Node_Id
)
return
Node_List
;
end
Ocarina
.
Lmp
;
src/python/ocarina-python_cmd.adb
View file @
d34317cd
...
...
@@ -34,14 +34,29 @@
pragma
Warnings
(
Off
);
-- Silence all warnings
with
GNATCOLL
.
Scripts
;
use
GNATCOLL
.
Scripts
;
with
GNATCOLL
.
Scripts
.
Python
;
use
GNATCOLL
.
Scripts
.
Python
;
with
GNATCOLL
.
Scripts
;
use
GNATCOLL
.
Scripts
;
with
GNATCOLL
.
Scripts
.
Python
;
use
GNATCOLL
.
Scripts
.
Python
;
with
Ocarina
.
Configuration
;
use
Ocarina
.
Configuration
;
with
Ocarina
.
Utils
;
with
Ocarina
.
Configuration
;
use
Ocarina
.
Configuration
;
with
GNATCOLL
.
VFS
;
use
GNATCOLL
.
VFS
;
with
Ocarina
.
Output
;
use
Ocarina
.
Output
;
with
Ocarina
.
Types
;
use
Ocarina
.
Types
;
with
Ocarina
.
Utils
;
use
Ocarina
.
Utils
;
with
Ocarina
.
Lmp
;
use
Ocarina
.
Lmp
;
with
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
.
Python
;
with
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
.
Python
;
with
Ocarina
.
ME_AADL
.
AADL_Tree
.
Entities
;
with
Ocarina
.
Namet
;
package
body
Ocarina
.
Python_Cmd
is
package
ATE
renames
Ocarina
.
ME_AADL
.
AADL_Tree
.
Entities
;
package
ATNP
renames
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
.
Python
;
package
AINP
renames
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
.
Python
;
--------------
-- On_Reset --
--------------
...
...
@@ -151,6 +166,349 @@ package body Ocarina.Python_Cmd is
Ocarina
.
Utils
.
Generate
(
Nth_Arg
(
Data
,
1
,
""
));
end
On_Generate
;
---------------------
-- On_Get_Packages --
---------------------
procedure
On_Get_Packages
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Packages
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Packages
);
end
On_Get_Packages
;
--------------------------------
-- On_Get_Import_Declarations --
--------------------------------
procedure
On_Get_Import_Declarations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Import_Declarations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Import_Declarations
);
end
On_Get_Import_Declarations
;
-------------------------------
-- On_Get_Alias_Declarations --
-------------------------------
procedure
On_Get_Alias_Declarations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Alias_Declarations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Alias_Declarations
);
end
On_Get_Alias_Declarations
;
----------------------------
-- On_Get_Component_Types --
----------------------------
procedure
On_Get_Component_Types
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Component_Types
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Component_Types
(
Nth_Arg
(
Data
,
1
,
""
)));
end
On_Get_Component_Types
;
--------------------------------------
-- On_Get_Component_Implementations --
--------------------------------------
procedure
On_Get_Component_Implementations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Component_Implementations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Component_Implementations
(
Nth_Arg
(
Data
,
1
,
""
)));
end
On_Get_Component_Implementations
;
--------------------
-- On_Get_Annexes --
--------------------
procedure
On_Get_Annexes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Annexes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Annexes
);
end
On_Get_Annexes
;
----------------------
-- On_Get_Prototype --
----------------------
procedure
On_Get_Prototype
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Prototype
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Prototype
);
end
On_Get_Prototype
;
------------------------------
-- On_Get_Prototype_Binding --
------------------------------
procedure
On_Get_Prototype_Binding
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Prototype_Binding
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Prototype_Binding
);
end
On_Get_Prototype_Binding
;
-----------------------
-- On_Get_Flow_Specs --
-----------------------
procedure
On_Get_Flow_Specs
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Flow_Specs
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Flow_Specs
);
end
On_Get_Flow_Specs
;
---------------------------------
-- On_Get_Flow_Implementations --
---------------------------------
procedure
On_Get_Flow_Implementations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Flow_Implementations
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Flow_Implementations
);
end
On_Get_Flow_Implementations
;
------------------
-- On_Get_Modes --
------------------
procedure
On_Get_Modes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Modes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Modes
);
end
On_Get_Modes
;
-----------------------------
-- On_Get_Mode_Transitions --
-----------------------------
procedure
On_Get_Mode_Transitions
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Mode_Transitions
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Mode_Transitions
);
end
On_Get_Mode_Transitions
;
---------------------
-- On_Get_In_Modes --
---------------------
procedure
On_Get_In_Modes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_In_Modes
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_In_Modes
);
end
On_Get_In_Modes
;
--------------------------
-- On_Get_Property_Sets --
--------------------------
-- procedure Get_PropertyBinding return Node_List;
procedure
On_Get_Property_Sets
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Property_Sets
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Property_Sets
);
end
On_Get_Property_Sets
;
---------------------------
-- On_Get_Property_Types --
---------------------------
procedure
On_Get_Property_Types
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Property_Types
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Property_Types
(
Get_Node_Id_From_String
(
Nth_Arg
(
Data
,
1
,
""
))));
end
On_Get_Property_Types
;
---------------------------------
-- On_Get_Property_Definitions --
---------------------------------
procedure
On_Get_Property_Definitions
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Property_Definitions
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin
ATNP
.
return_List
(
Data
,
Get_Property_Definitions
(
Get_Node_Id_From_String
(
Nth_Arg
(
Data
,
1
,
""
))));
end
On_Get_Property_Definitions
;
------------------------------
-- On_Get_PropertyConstants --
------------------------------
procedure
On_Get_PropertyConstants
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_PropertyConstants
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
List_Node
:
Node_Id
;
begin