ocarina.py 1.76 KB
Newer Older
yoogx's avatar
yoogx committed
1
2
3
4
5
6
#! /usr/bin/python
'''Python binding to the Ocarina AADL processor'''

################################################################################
import libocarina_python; # Ocarina bindings

yoogx's avatar
yoogx committed
7
8
class Enum(tuple): __getattr__ = tuple.index

yoogx's avatar
yoogx committed
9
10
11
12
13
14
15
16
17
18
19
20
################################################################################
def version ():
    '''Print Ocarina version'''
    libocarina_python.version();

################################################################################
def status ():
    '''Print Ocarina status'''
    libocarina_python.status();

################################################################################
def load (filename):
yoogx's avatar
yoogx committed
21
22
23
24
25
26
27
28
29
30
    '''Load a file

    :param filename: name of the file to be loaded, following Ocarina search path
    :type filename: string

    E.g. to load "foo.aadl":

    >>> load("foo.aadl");

    '''
yoogx's avatar
yoogx committed
31
32
33
34
35
36
37
38
39
40
41
42
43
    libocarina_python.load (filename);

################################################################################
def analyze ():
    '''Analyze models'''
    libocarina_python.analyze ();

################################################################################
def instantiate (root_system):
    '''Instantiate models'''
    libocarina_python.instantiate (root_system);

################################################################################
yoogx's avatar
yoogx committed
44
45
46
Backends = Enum ([ "polyorb_hi_ada", "polyorb_hi_c"]);
'''Supported backends'''

yoogx's avatar
yoogx committed
47
def generate (generator):
yoogx's avatar
yoogx committed
48
    '''Generate code
yoogx's avatar
yoogx committed
49

yoogx's avatar
yoogx committed
50
51
52
    :param generator: one supported backends, from :data:`Backends`

    For instance, to use the PolyORB-HI/Ada backend, you may use the following
yoogx's avatar
yoogx committed
53

yoogx's avatar
yoogx committed
54
55
56
    >>> generate (Backends.polyorb_hi_ada);
    '''
    libocarina_python.generate (Backends[generator]);
yoogx's avatar
yoogx committed
57
58
59

################################################################################