1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--            O C A R I N A . B A C K E N D S . A I R _ C O N F             --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2018-2019 ESA & ISAE, 2019-2020 OpenAADL           --
10
--                                                                          --
11
-- Ocarina  is free software; you can redistribute it and/or modify under   --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
15
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
16
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
--                    Ocarina is maintained by OpenAADL team                --
28
--                              (info@openaadl.org)                         --
29
--                                                                          --
30
------------------------------------------------------------------------------
31

32
with Ocarina.Instances;
33
with Ocarina.Backends.Messages;
34
with Ocarina.Backends.Expander;
35
with Ocarina.ME_AADL.AADL_Instances.Nodes;
36
with Ocarina.Backends.XML_Tree.Nodes;
37
with Ocarina.Backends.XML_Tree.Nutils;
38
with Ocarina.Backends.XML_Tree.Generator;
39
with Ocarina.Backends.Utils;
40

41
with Ocarina.Namet; use Ocarina.Namet;
42

43
with Ocarina.Backends.AIR_Conf.Module;
44
with Ocarina.Backends.AIR_Conf.AIR_Configuration;
45
with Ocarina.Backends.AIR_Conf.Partitions;
46

47
package body Ocarina.Backends.AIR_Conf is
48

49
   use Ocarina.Instances;
50
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
51
   use Ocarina.Backends.Expander;
52
   use Ocarina.Backends.Messages;
53
   use Ocarina.Backends.Utils;
54

55
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
56
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
57

58
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
59

60
   --------------
61
   -- Generate --
62
   --------------
63

64 1
   procedure Generate (AADL_Root : Node_Id) is
65 1
      Instance_Root : Node_Id;
66
   begin
67

68 1
      Instance_Root := Instantiate_Model (AADL_Root);
69

70 1
      Expand (Instance_Root);
71

72 1
      Visit_Architecture_Instance (Instance_Root);
73
      --  Abort if the construction of the tree failed
74

75 1
      if No (XML_Root) then
76 0
         Display_Error
77
           ("AIR configuration generation failed",
78
            Fatal => True);
79
      end if;
80

81
      --  At this point, we have a valid tree, we can begin the XML
82
      --  file generation.
83

84
      --  Enter the output directory
85

86 1
      Enter_Directory (Generated_Sources_Directory);
87

88 1
      if not Remove_Generated_Sources then
89
         --  Create the source files
90

91 1
         XML_Tree.Generator.Generate (XML_Root);
92

93
      end if;
94

95
      --  Leave the output directory
96 1
      Leave_Directory;
97 1
   end Generate;
98

99
   ----------
100
   -- Init --
101
   ----------
102

103 1
   procedure Init is
104
   begin
105 1
      Register_Backend
106
        ("AIR_Configuration",
107
         Generate'Access,
108
         AIR_Configuration_Backend);
109 1
   end Init;
110

111
   -----------
112
   -- Reset --
113
   -----------
114

115 0
   procedure Reset is
116
   begin
117 0
      null;
118 0
   end Reset;
119

120
   ---------------------------------
121
   -- Visit_Architecture_Instance --
122
   ---------------------------------
123

124 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
125
   begin
126 1
      XML_Root := XTU.New_Node (XTN.K_HI_Distributed_Application);
127 1
      Get_Name_String
128 1
        (Normalize_Name (AIN.Name (AIN.Identifier (Root_System (E)))));
129 1
      XTN.Set_Name (XML_Root, Name_Find);
130 1
      XTN.Set_Units (XML_Root, XTU.New_List (XTN.K_List_Id));
131 1
      XTN.Set_HI_Nodes (XML_Root, XTU.New_List (XTN.K_List_Id));
132

133 1
      XTU.Push_Entity (XML_Root);
134

135 1
      Module.Visit (E);
136 1
      Partitions.Visit (E);
137 1
      AIR_Configuration.Visit (E);
138

139 1
      XTU.Pop_Entity;
140 1
   end Visit_Architecture_Instance;
141

142
   ------------------
143
   -- Get_XML_Root --
144
   ------------------
145

146 0
   function Get_XML_Root return Node_Id is
147
   begin
148 0
      return XML_Root;
149
   end Get_XML_Root;
150

151
end Ocarina.Backends.AIR_Conf;

Read our documentation on viewing source code .

Loading