OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--           O C A R I N A . B A C K E N D S . D E O S _ C O N F            --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2014-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.Backends.XML_Tree.Nodes;
36
with Ocarina.Backends.XML_Tree.Nutils;
37
with Ocarina.Backends.XML_Tree.Generator;
38
with Ocarina.Backends.Deos_Conf.Hm;
39
with Ocarina.Backends.Deos_Conf.Schedule;
40
with Ocarina.Backends.Deos_Conf.Naming;
41
with Ocarina.Backends.Deos_Conf.Partitions;
42
with Ocarina.Backends.Utils;
43

44
with Ocarina.Namet; use Ocarina.Namet;
45

46
package body Ocarina.Backends.Deos_Conf is
47

48
   use Ocarina.Instances;
49
   use Ocarina.Backends.Expander;
50
   use Ocarina.Backends.Messages;
51
   use Ocarina.Backends.Utils;
52

53
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
54
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
55

56
   --------------
57
   -- Generate --
58
   --------------
59

60 1
   procedure Generate (AADL_Root : Node_Id) is
61 1
      Instance_Root : Node_Id;
62
   begin
63

64 1
      Instance_Root := Instantiate_Model (AADL_Root);
65

66 1
      Expand (Instance_Root);
67

68 1
      Visit_Architecture_Instance (Instance_Root);
69
      --  Abort if the construction of the tree failed
70

71 1
      if No (XML_Root) then
72 0
         Display_Error ("Deos configuration generation failed", Fatal => True);
73
      end if;
74

75
      --  At this point, we have a valid tree, we can begin the XML
76
      --  file generation.
77

78
      --  Enter the output directory
79

80 1
      Enter_Directory (Generated_Sources_Directory);
81

82 1
      if not Remove_Generated_Sources then
83
         --  Create the source files
84

85 1
         XML_Tree.Generator.Generate (XML_Root);
86

87
      end if;
88

89
      --  Leave the output directory
90 1
      Leave_Directory;
91 1
   end Generate;
92

93
   ----------
94
   -- Init --
95
   ----------
96

97 1
   procedure Init is
98
   begin
99 1
      Register_Backend ("Deos_Conf", Generate'Access, Deos_XML);
100 1
   end Init;
101

102
   -----------
103
   -- Reset --
104
   -----------
105

106 0
   procedure Reset is
107
   begin
108 0
      null;
109 0
   end Reset;
110

111
   ---------------------------------
112
   -- Visit_Architecture_Instance --
113
   ---------------------------------
114

115 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
116
   begin
117 1
      XML_Root := XTU.New_Node (XTN.K_HI_Distributed_Application);
118 1
      Set_Str_To_Name_Buffer ("generated-code");
119 1
      XTN.Set_Name (XML_Root, Name_Find);
120 1
      XTN.Set_Units (XML_Root, XTU.New_List (XTN.K_List_Id));
121 1
      XTN.Set_HI_Nodes (XML_Root, XTU.New_List (XTN.K_List_Id));
122

123 1
      XTU.Push_Entity (XML_Root);
124

125 1
      Deos_Conf.Naming.Visit (E);
126 1
      Deos_Conf.Partitions.Visit (E);
127 1
      Deos_Conf.Schedule.Visit (E);
128 1
      Deos_Conf.Hm.Visit (E);
129

130 1
      XTU.Pop_Entity;
131

132 1
   end Visit_Architecture_Instance;
133

134
   ------------------
135
   -- Get_XML_Root --
136
   ------------------
137

138 0
   function Get_XML_Root return Node_Id is
139
   begin
140 0
      return XML_Root;
141
   end Get_XML_Root;
142

143
end Ocarina.Backends.Deos_Conf;

Read our documentation on viewing source code .

Loading