test.py 2.07 KB
Newer Older
yoogx's avatar
yoogx committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/python

import OcarinaPython as ocarina;

def visitor (component,level) :
    subcomponents=ocarina.AIN.Subcomponents(component);
    if subcomponents is not None :
       prefix=''
       while ( len(prefix)<level ) :
          prefix=prefix+'.'
       for child in subcomponents :
          print prefix,ocarina.getInstanceName(child)[0]
          visitor(str(ocarina.AIN.Corresponding_Instance(child)),level+1)

def main ():
    '''Test function'''

    err=ocarina.load("rma.aadl");                   # load a file
    print 'load("rma.aadl")'
    if err[1].strip()!='':
      print 'info message: \n', err[1]
    if err[2]!=[]:
      print 'warning message: \n', err[2]
    if err[3]!=[]:
      print 'error message: \n', err[3]
      sys.exit(2)
      
    err=ocarina.load("deployment.aadl");            # load a file
    print 'load("deployment.aadl")'
    if err[1].strip()!='':
      print 'info message: \n', err[1]
    if err[2]!=[]:
      print 'warning message: \n', err[2]
    if err[3]!=[]:
      print 'error message: \n', err[3]
      sys.exit(2)
      
    err=ocarina.analyze();                          # analyze models
    print 'ocarina.analyze()'
    if err[1].strip()!='':
      print 'info message: \n', err[1]
    if err[2]!=[]:
      print 'warning message: \n', err[2]
    if err[3]!=[]:
      print 'error message: \n', err[3]
      sys.exit(2)
      
    err=ocarina.instantiate("rma.erc32");           # instantiate system
    print 'ocarina.instantiate("rma.erc32")'
    if err[1].strip()!='':
      print 'info message: \n', err[1]
    if err[2]!=[]:
      print 'warning message: \n', err[2]
    if err[3]!=[]:
      print 'error message: \n', err[3]
      sys.exit(2)
    
    print '----------------------------------------------------'
    print 'Number of Component Instances:'
    print '----------------------------------------------------'
    root=ocarina.getInstances('all')[0][0]
    # root=ocarina.getRoot()
    print ocarina.getInstanceName(root)[0]
    visitor(root,1)

if __name__ == "__main__":
    main ()
    sys.exit (0);                       # exit