1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--                 OCARINA.BACKENDS.XTRATUM_CONF.CHANNELS                   --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2011-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 Utils;         use Utils;
33
with Ocarina.Namet; use Ocarina.Namet;
34
with Ocarina.ME_AADL;
35
with Ocarina.ME_AADL.AADL_Instances.Nodes;
36
with Ocarina.ME_AADL.AADL_Instances.Nutils;
37
with Ocarina.ME_AADL.AADL_Instances.Entities;
38

39
with Ocarina.Backends.Properties;
40
with Ocarina.Backends.Utils;
41
with Ocarina.Backends.XML_Tree.Nodes;
42
with Ocarina.Backends.XML_Tree.Nutils;
43
with Ocarina.Backends.XML_Values;
44

45
package body Ocarina.Backends.Xtratum_Conf.Channels is
46

47
   use Ocarina.ME_AADL;
48
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
49
   use Ocarina.ME_AADL.AADL_Instances.Entities;
50

51
   use Ocarina.Backends.Utils;
52

53
   use Ocarina.Backends.Properties;
54
   use Ocarina.Backends.XML_Tree.Nutils;
55

56
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
57
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
58
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
59
   package XV renames Ocarina.Backends.XML_Values;
60

61
   procedure Visit_Architecture_Instance (E : Node_Id);
62
   procedure Visit_Component_Instance (E : Node_Id);
63
   procedure Visit_System_Instance (E : Node_Id);
64
   procedure Visit_Processor_Instance (E : Node_Id);
65
   procedure Visit_Virtual_Processor_Instance (E : Node_Id);
66
   procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
67

68
   -----------
69
   -- Visit --
70
   -----------
71

72 1
   procedure Visit (E : Node_Id) is
73
   begin
74
      case Kind (E) is
75 1
         when K_Architecture_Instance =>
76 1
            Visit_Architecture_Instance (E);
77

78 1
         when K_Component_Instance =>
79 1
            Visit_Component_Instance (E);
80

81 0
         when others =>
82 0
            null;
83
      end case;
84 1
   end Visit;
85

86
   ---------------------------------
87
   -- Visit_Architecture_Instance --
88
   ---------------------------------
89

90 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
91
   begin
92 1
      Visit (Root_System (E));
93 1
   end Visit_Architecture_Instance;
94

95
   ------------------------------
96
   -- Visit_Component_Instance --
97
   ------------------------------
98

99 1
   procedure Visit_Component_Instance (E : Node_Id) is
100 1
      Category : constant Component_Category := Get_Category_Of_Component (E);
101
   begin
102
      case Category is
103 1
         when CC_System =>
104 1
            Visit_System_Instance (E);
105

106 1
         when CC_Processor =>
107 1
            Visit_Processor_Instance (E);
108

109 1
         when CC_Virtual_Processor =>
110 1
            Visit_Virtual_Processor_Instance (E);
111

112 1
         when others =>
113 1
            null;
114 1
      end case;
115 1
   end Visit_Component_Instance;
116

117
   ---------------------------
118
   -- Visit_System_Instance --
119
   ---------------------------
120

121 1
   procedure Visit_System_Instance (E : Node_Id) is
122 1
      C                     : Node_Id;
123 1
      U                     : Node_Id;
124 1
      R                     : Node_Id;
125 1
      P                     : Node_Id;
126 1
      Q                     : Node_Id;
127 1
      Queue_Size            : Unsigned_Long_Long;
128 1
      Source_Port_Name      : Name_Id;
129 1
      Destination_Port_Name : Name_Id;
130 1
      Destination_Partition : Node_Id;
131 1
      Source_Partition      : Node_Id;
132 1
      Source_Port           : Node_Id;
133 1
      Associated_Data_Size  : Unsigned_Long_Long;
134 1
      Destination_Port      : Node_Id;
135 1
      Channels_Node         : Node_Id;
136 1
      Channel_Node          : Node_Id;
137 1
      Source_Node           : Node_Id;
138 1
      Destination_Node      : Node_Id;
139
   begin
140 1
      U := XTN.Unit (Backend_Node (Identifier (E)));
141 1
      R := XTN.Node (Backend_Node (Identifier (E)));
142

143 1
      Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
144

145 1
      Push_Entity (U);
146 1
      Push_Entity (R);
147

148 1
      if not AINU.Is_Empty (Connections (E)) then
149

150 1
         Channels_Node := Make_XML_Node ("Channels");
151

152 1
         C := First_Node (Connections (E));
153 1
         while Present (C) loop
154 1
            if Kind (C) = K_Connection_Instance then
155

156
               Source_Port :=
157 1
                 (AIN.Item
158 1
                    (AIN.Next_Node
159 1
                       (AIN.First_Node (AIN.Path (AIN.Source (C))))));
160

161
               Destination_Port :=
162 1
                 AIN.Item
163 1
                   (AIN.Next_Node
164 1
                      (AIN.First_Node (AIN.Path (AIN.Destination (C)))));
165

166
               Source_Port_Name :=
167 1
                 AIN.Name
168 1
                   (AIN.Identifier
169 1
                      (AIN.Item
170 1
                         (AIN.Next_Node
171 1
                            (AIN.First_Node (AIN.Path (AIN.Source (C)))))));
172

173
               Destination_Port_Name :=
174 1
                 AIN.Name
175 1
                   (AIN.Identifier
176 1
                      (AIN.Item
177 1
                         (AIN.Next_Node
178 1
                            (AIN.First_Node
179 1
                               (AIN.Path (AIN.Destination (C)))))));
180

181
               Source_Partition :=
182 1
                 AIN.Corresponding_Instance
183 1
                   (AIN.Item (AIN.First_Node (AIN.Path (AIN.Source (C)))));
184

185
               Destination_Partition :=
186 1
                 AIN.Corresponding_Instance
187 1
                   (AIN.Item
188 1
                      (AIN.First_Node (AIN.Path (AIN.Destination (C)))));
189 1
               if not Is_Event (Source_Port) then
190 1
                  Channel_Node := Make_XML_Node ("SamplingChannel");
191
               else
192 1
                  Channel_Node := Make_XML_Node ("QueuingChannel");
193 1
                  Set_Str_To_Name_Buffer ("maxNoMessages");
194 1
                  P := Make_Defining_Identifier (Name_Find);
195 1
                  Get_Name_String (Source_Port_Name);
196

197 1
                  if Get_Queue_Size (Destination_Port) = -1 then
198 1
                     Queue_Size := 1;
199
                  else
200 0
                     Queue_Size :=
201 0
                       Unsigned_Long_Long (Get_Queue_Size (Destination_Port));
202
                  end if;
203 1
                  Q := Make_Literal (XV.New_Numeric_Value (Queue_Size, 1, 10));
204 1
                  Append_Node_To_List
205 1
                    (Make_Assignement (P, Q),
206 1
                     XTN.Items (Channel_Node));
207
               end if;
208

209 1
               Source_Node      := Make_XML_Node ("Source");
210 1
               Destination_Node := Make_XML_Node ("Destination");
211

212 1
               Set_Str_To_Name_Buffer ("maxMessageLength");
213 1
               P := Make_Defining_Identifier (Name_Find);
214 1
               Get_Name_String (Source_Port_Name);
215

216 1
               if Get_Data_Size (Corresponding_Instance (Source_Port)) /=
217
                 Null_Size
218
               then
219 1
                  Associated_Data_Size :=
220 1
                    To_Bytes
221 1
                      (Get_Data_Size (Corresponding_Instance (Source_Port)));
222
               else
223 1
                  Associated_Data_Size := 1;
224
               end if;
225

226 1
               Set_Str_To_Name_Buffer
227 1
                 (Unsigned_Long_Long'Image (Associated_Data_Size));
228 1
               Add_Str_To_Name_Buffer ("B");
229 1
               Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
230

231 1
               Append_Node_To_List
232 1
                 (Make_Assignement (P, Q),
233 1
                  XTN.Items (Channel_Node));
234

235 1
               Set_Str_To_Name_Buffer ("portName");
236 1
               P := Make_Defining_Identifier (Name_Find);
237 1
               Get_Name_String (Source_Port_Name);
238 1
               Q := Make_Defining_Identifier (Name_Find);
239 1
               Append_Node_To_List
240 1
                 (Make_Assignement (P, Q),
241 1
                  XTN.Items (Source_Node));
242

243 1
               Set_Str_To_Name_Buffer ("partitionId");
244 1
               P := Make_Defining_Identifier (Name_Find);
245 1
               Get_Name_String (Source_Port_Name);
246
               Q :=
247 1
                 Copy_Node
248 1
                   (Backend_Node
249 1
                      (Identifier (Get_Bound_Processor (Source_Partition))));
250 1
               Append_Node_To_List
251 1
                 (Make_Assignement (P, Q),
252 1
                  XTN.Items (Source_Node));
253

254 1
               Set_Str_To_Name_Buffer ("partitionId");
255 1
               P := Make_Defining_Identifier (Name_Find);
256 1
               Get_Name_String (Source_Port_Name);
257
               Q :=
258 1
                 Copy_Node
259 1
                   (Backend_Node
260 1
                      (Identifier
261 1
                         (Get_Bound_Processor (Destination_Partition))));
262 1
               Append_Node_To_List
263 1
                 (Make_Assignement (P, Q),
264 1
                  XTN.Items (Destination_Node));
265

266 1
               Set_Str_To_Name_Buffer ("portName");
267 1
               P := Make_Defining_Identifier (Name_Find);
268 1
               Get_Name_String (Destination_Port_Name);
269 1
               Q := Make_Defining_Identifier (Name_Find);
270 1
               Append_Node_To_List
271 1
                 (Make_Assignement (P, Q),
272 1
                  XTN.Items (Destination_Node));
273

274 1
               Set_Str_To_Name_Buffer ("partitionName");
275 1
               P := Make_Defining_Identifier (Name_Find);
276 1
               Get_Name_String
277 1
                 (To_Lower
278 1
                    (Display_Name
279 1
                       (Identifier
280 1
                          (Parent_Subcomponent (Destination_Partition)))));
281 1
               Q := Make_Defining_Identifier (Name_Find);
282 1
               Append_Node_To_List
283 1
                 (Make_Assignement (P, Q),
284 1
                  XTN.Items (Destination_Node));
285

286 1
               Append_Node_To_List (Source_Node, XTN.Subitems (Channel_Node));
287 1
               Append_Node_To_List
288
                 (Destination_Node,
289 1
                  XTN.Subitems (Channel_Node));
290 1
               Append_Node_To_List
291
                 (Channel_Node,
292 1
                  XTN.Subitems (Channels_Node));
293
            end if;
294

295 1
            C := Next_Node (C);
296 1
         end loop;
297

298 1
         Append_Node_To_List (Channels_Node, XTN.Subitems (Current_XML_Node));
299
      end if;
300

301 1
      Visit_Subcomponents_Of (E);
302

303 1
      Pop_Entity;
304 1
      Pop_Entity;
305 1
   end Visit_System_Instance;
306

307
   ------------------------------
308
   -- Visit_Processor_Instance --
309
   ------------------------------
310

311 1
   procedure Visit_Processor_Instance (E : Node_Id) is
312
   begin
313 1
      Visit_Subcomponents_Of (E);
314 1
   end Visit_Processor_Instance;
315

316
   --------------------------------------
317
   -- Visit_Virtual_Processor_Instance --
318
   --------------------------------------
319

320 1
   procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
321
   begin
322 1
      Visit_Subcomponents_Of (E);
323 1
   end Visit_Virtual_Processor_Instance;
324

325
end Ocarina.Backends.Xtratum_Conf.Channels;

Read our documentation on viewing source code .

Loading