Commit 624feb74 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add package to parse deployment view

parent 41dfc1ad
...@@ -6,7 +6,6 @@ pragma Warnings (Off); ...@@ -6,7 +6,6 @@ pragma Warnings (Off);
with Ada.Strings.Unbounded, with Ada.Strings.Unbounded,
Ada.Command_Line, Ada.Command_Line,
Ada.Exceptions, Ada.Exceptions,
Ada.Text_IO, Ada.Text_IO,
Ada.Containers.Indefinite_Vectors, Ada.Containers.Indefinite_Vectors,
GNAT.OS_Lib, GNAT.OS_Lib,
...@@ -26,7 +25,8 @@ with Ada.Strings.Unbounded, ...@@ -26,7 +25,8 @@ with Ada.Strings.Unbounded,
Ocarina.Parser, Ocarina.Parser,
Ocarina.FE_AADL.Parser, Ocarina.FE_AADL.Parser,
Parser_Utils, Parser_Utils,
Interface_View; Interface_View,
Deployment_View;
use Ada.Strings.Unbounded, use Ada.Strings.Unbounded,
Ada.Text_IO, Ada.Text_IO,
...@@ -45,6 +45,7 @@ use Ada.Strings.Unbounded, ...@@ -45,6 +45,7 @@ use Ada.Strings.Unbounded,
Ocarina.Backends.Properties, Ocarina.Backends.Properties,
Parser_Utils, Parser_Utils,
Interface_View, Interface_View,
Deployment_View,
GNAT.OS_Lib; GNAT.OS_Lib;
procedure AADL_Parser is procedure AADL_Parser is
...@@ -142,110 +143,6 @@ procedure AADL_Parser is ...@@ -142,110 +143,6 @@ procedure AADL_Parser is
----------------------------- -----------------------------
procedure Process_Deployment_View (My_Root : Node_Id) is null; procedure Process_Deployment_View (My_Root : Node_Id) is null;
-- My_Root_System : Node_Id;
-- CI : Node_Id;
-- Root_Instance : Node_Id;
-- begin
--
-- if My_Root /= No_Node and then Concurrency_view /= 0 then
-- -- Analyze the tree
--
-- Success := Ocarina.Analyzer.Analyze (AADL_Language, My_Root);
-- Exit_On_Error (not Success, "Deployment view is incorrect");
-- if Success then
-- -- After making sure that the Deployment view is correct, set
-- -- the Glue flag
--
-- if generate_glue then
-- C_Set_Glue;
-- end if;
--
-- -- Put_Line (Get_Name_String
-- -- (Get_Ellidiss_Tool_Version (My_Root)));
--
-- Ocarina.Options.Root_System_Name :=
-- Get_String_Name ("deploymentview.others");
--
-- -- Instantiate AADL tree
-- Root_Instance := Instantiate_Model (Root => My_Root);
--
-- My_Root_System := Root_System (Root_Instance);
--
-- -- Name of the ROOT SYSTEM (not implementation)
--
-- declare
-- My_Root_System_Name : constant String :=
-- Get_Name_String
-- (Ocarina.ME_AADL.AADL_Tree.Nodes.Name
-- (Ocarina.ME_AADL.AADL_Tree.Nodes.
-- Component_Type_Identifier
-- (Corresponding_Declaration
-- (My_Root_System))));
-- begin
-- C_Set_Root_node
-- (My_Root_System_Name, My_Root_System_Name'Length);
-- end;
--
-- if not Is_Empty (Subcomponents (My_Root_System)) then
-- Subs := First_Node (Subcomponents (My_Root_System));
--
-- while Present (Subs) loop
-- CI := Corresponding_Instance (Subs);
--
-- if Get_Category_Of_Component (CI) = CC_System then
-- Browse_Deployment_View_System
-- (CI, Get_Name_String (Name (Identifier (Subs))));
-- elsif Get_Category_Of_Component (CI) = CC_Bus then
-- declare
-- -- Get the list of properties attaches to the bus
-- Properties : constant Property_Maps.Map :=
-- Get_Properties_Map (CI);
-- Bus_Classifier : Name_Id := No_Name;
-- Pkg_Name : Name_Id := No_Name;
-- begin
-- -- Iterate on the BUS Instance properties
-- for each in Properties.Iterate loop
-- null;
-- -- Put_Line (Property_Maps.Key (each) & " : " &
-- -- Property_Maps.Element (each));
-- end loop;
-- Set_Str_To_Name_Buffer ("");
-- if ATN.Namespace
-- (Corresponding_Declaration (CI)) /= No_Node
-- then
-- Set_Str_To_Name_Buffer ("");
-- Get_Name_String
-- (ATN.Name
-- (ATN.Identifier
-- (ATN.Namespace
-- (Corresponding_Declaration (CI)))));
-- Pkg_Name := Name_Find;
-- C_Add_Package
-- (Get_Name_String (Pkg_Name),
-- Get_Name_String (Pkg_Name)'Length);
-- Set_Str_To_Name_Buffer ("");
-- Get_Name_String (Pkg_Name);
-- Add_Str_To_Name_Buffer ("::");
-- Get_Name_String_And_Append
-- (Name (Identifier (CI)));
-- Bus_Classifier := Name_Find;
-- else
-- Bus_Classifier := Name (Identifier (CI));
-- end if;
-- C_New_Bus
-- (Get_Name_String (Name (Identifier (Subs))),
-- Get_Name_String (Name (Identifier (Subs)))'Length,
-- Get_Name_String (Bus_Classifier),
-- Get_Name_String (Bus_Classifier)'Length);
-- C_End_Bus;
-- end;
-- end if;
-- Subs := Next_Node (Subs);
-- end loop;
-- end if;
-- end if;
-- end if;
-- end Process_Deployment_View;
------------------------------------- -------------------------------------
-- Load_Deployment_View_Properties -- -- Load_Deployment_View_Properties --
......
-- *************************** taste aadl parser *********************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Deployment View parser
with -- Ada.Text_IO,
-- Ada.Exceptions,
-- Ocarina.Instances.Queries,
Ocarina.Instances,
Ocarina.Namet,
Ocarina.Analyzer,
Ocarina.Options,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.ME_AADL.AADL_Instances.Entities;
-- Ocarina.Backends.Utils;
package body Deployment_View is
use -- Ada.Text_IO,
-- Ada.Exceptions,
-- Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.ME_AADL.AADL_Instances.Entities,
Ocarina.ME_AADL;
-- Ocarina.Backends.Utils;
function Initialize (Root : Node_Id) return Node_Id is
Success : Boolean;
Root_Instance : Node_Id;
AADL_Language : constant Name_Id := Get_String_Name ("aadl");
begin
Success := Ocarina.Analyzer.Analyze (AADL_Language, Root);
if not Success then
raise Deployment_View_Error with "Deployment view is incorrect";
end if;
Ocarina.Options.Root_System_Name :=
Get_String_Name ("deploymentview.others");
-- Instantiate AADL tree
Root_Instance := Ocarina.Instances.Instantiate_Model (Root => Root);
return Root_System (Root_Instance);
end Initialize;
---------------------------
-- AST Builder Functions --
---------------------------
function AADL_To_Ada_DV (System : Node_Id) return Complete_Deployment_View
is
use type Node_Maps.Map;
use type Taste_Busses.Vector;
Nodes : Node_Maps.Map;
Busses : Taste_Busses.Vector;
My_Root_System : Node_Id;
Subs : Node_Id;
CI : Node_Id;
function Parse_Bus (Elem : Node_Id; Bus : Node_Id) return Taste_Bus is
Properties : constant Property_Maps.Map := Get_Properties_Map (CI);
Classifier : Name_Id := No_Name;
Pkg_Name : Name_Id := No_Name;
begin
Set_Str_To_Name_Buffer ("");
if ATN.Namespace
(Corresponding_Declaration (Bus)) /= No_Node
then
Set_Str_To_Name_Buffer ("");
Get_Name_String
(ATN.Name
(ATN.Identifier
(ATN.Namespace
(Corresponding_Declaration (Bus)))));
Pkg_Name := Name_Find;
-- C_Add_Package
-- (Get_Name_String (Pkg_Name),
Set_Str_To_Name_Buffer ("");
Get_Name_String (Pkg_Name);
Add_Str_To_Name_Buffer ("::");
Get_Name_String_And_Append
(Name (Identifier (Bus)));
Classifier := Name_Find;
else
Classifier := Name (Identifier (Bus));
end if;
return Taste_Bus'(Name =>
US (Get_Name_String (Name (Identifier (Elem)))),
Classifier => US (Get_Name_String (Classifier)),
Properties => Properties);
end Parse_Bus;
begin
My_Root_System := Initialize (System);
if Is_Empty (Subcomponents (My_Root_System)) then
raise Empty_Deployment_View_Error;
end if;
Subs := First_Node (Subcomponents (My_Root_System));
while Present (Subs) loop
CI := Corresponding_Instance (Subs);
if Get_Category_Of_Component (CI) = CC_System then
null;
-- Browse_Deployment_View_System
-- (CI, Get_Name_String (Name (Identifier (Subs))));
elsif Get_Category_Of_Component (CI) = CC_Bus then
Busses.Append (Parse_Bus (Subs, CI));
end if;
Subs := Next_Node (Subs);
end loop;
return DV_AST : constant Complete_Deployment_View :=
(Nodes => Nodes,
Busses => Busses);
end AADL_To_Ada_DV;
procedure Debug_Dump_DV (DV : Complete_Deployment_View) is null;
end Deployment_View;
-- *************************** taste aadl parser *********************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Deployment View parser
with Ocarina,
Ocarina.Types,
-- Ocarina.Backends.Properties,
Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded,
-- Option_Type,
Parser_Utils;
use Ocarina,
Ocarina.Types,
-- Ocarina.Backends.Properties,
Ada.Containers,
Ada.Strings.Unbounded,
Parser_Utils;
package Deployment_View is
use Option_UString;
use Option_ULL;
-- Exceptions specific to the deployment view
Deployment_View_Error : exception;
Empty_Deployment_View_Error : exception;
-- Initialize Ocarina and instantiate the deployment view, return root.
function Initialize (Root : Node_Id) return Node_Id
with Pre => Root /= No_Node;
type Taste_Node is
record
Name : Unbounded_String;
end record;
package Node_Maps is new Indefinite_Ordered_Maps (String, Taste_Node);
type Taste_Bus is
record
Name : Unbounded_String;
Classifier : Unbounded_String;
Properties : Property_Maps.Map;
end record;
package Taste_Busses is new Indefinite_Vectors (Natural, Taste_Bus);
type Complete_Deployment_View is tagged
record
Nodes : Node_Maps.Map;
Busses : Taste_Busses.Vector;
end record;
-- Function to build up the Ada AST by transforming the one from Ocarina
function AADL_To_Ada_DV (System : Node_Id) return Complete_Deployment_View;
procedure Debug_Dump_DV (DV : Complete_Deployment_View);
end Deployment_View;
...@@ -5,25 +5,189 @@ ...@@ -5,25 +5,189 @@
-- generated code: do not edit -- generated code: do not edit
--------------------------------------------------- ---------------------------------------------------
PACKAGE deploymentview::DV::Node1
PUBLIC
WITH ocarina_buses;
WITH ocarina_drivers;
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS first_binary
END first_binary;
PROCESS IMPLEMENTATION first_binary.others
END first_binary.others;
DEVICE generic_sockets_ip_pohic
EXTENDS ocarina_drivers::generic_sockets_ip
FEATURES
link : REFINED TO REQUIRES BUS ACCESS ocarina_buses::ip.i {
Taste::coordinates => "110053 88536";
};
PROPERTIES
Taste::Interface_Coordinates => "123691 102645" APPLIES TO link;
Deployment::Help => "Write your ASN.1 configuration here";
Deployment::Configuration => "{devname ""eth0"", address ""127.0.0.1"", port 5115}";
Deployment::Config => "/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn";
Deployment::Version => "0.1beta";
END generic_sockets_ip_pohic;
DEVICE IMPLEMENTATION generic_sockets_ip_pohic.others
EXTENDS ocarina_drivers::generic_sockets_ip.pohic
END generic_sockets_ip_pohic.others;
END deploymentview::DV::Node1;
PACKAGE deploymentview::DV::Node2
PUBLIC
WITH ocarina_buses;
WITH ocarina_drivers;
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS second_binary
END second_binary;
PROCESS IMPLEMENTATION second_binary.others
END second_binary.others;
DEVICE generic_sockets_ip_pohic
EXTENDS ocarina_drivers::generic_sockets_ip
FEATURES
link : REFINED TO REQUIRES BUS ACCESS ocarina_buses::ip.i {
Taste::coordinates => "165431 84480";
};
PROPERTIES
Taste::Interface_Coordinates => "158141 102645" APPLIES TO link;
Deployment::Help => "Write your ASN.1 configuration here";
Deployment::Configuration => "{devname ""eth0"", address ""127.0.0.1"", port 5116}";
Deployment::Config => "/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn";
Deployment::Version => "0.1beta";
END generic_sockets_ip_pohic;
DEVICE IMPLEMENTATION generic_sockets_ip_pohic.others
EXTENDS ocarina_drivers::generic_sockets_ip.pohic
END generic_sockets_ip_pohic.others;
END deploymentview::DV::Node2;
PACKAGE deploymentview::DV PACKAGE deploymentview::DV
PUBLIC PUBLIC
WITH interfaceview::IV::Level0_Appear;
WITH ocarina_processors_x86;
WITH deploymentview::DV::Node1;
WITH interfaceview::IV::Function1_ShouldNotAppear::Nested1_Appear;
WITH interfaceview::IV::Function1_ShouldNotAppear::Should_Not_Appear_Either::Nested2_Appear;
WITH interfaceview::IV::Function1_ShouldNotAppear::MotherClass_Appear;
WITH interfaceview::IV::Y_Hidden::Z_Shown;
WITH deploymentview::DV::Node2;
WITH ocarina_buses;
WITH Taste; WITH Taste;
WITH Deployment; WITH Deployment;
WITH interfaceview::IV; WITH interfaceview::IV;
WITH TASTE_DV_Properties; WITH TASTE_DV_Properties;
SYSTEM Node1
FEATURES
generic_sockets_ip_pohic_ip_i : REQUIRES BUS ACCESS ocarina_buses::ip.i;
END Node1;
SYSTEM IMPLEMENTATION Node1.others
SUBCOMPONENTS
IV_Level0_Appear : SYSTEM interfaceview::IV::Level0_Appear::Level0_Appear.others {
Taste::FunctionName => "Level0_Appear";
};
first_binary : PROCESS deploymentview::DV::Node1::first_binary.others {
Taste::coordinates => "97495 54172 119317 74971";
Deployment::Port_Number => 0;
};
x86_linux : PROCESSOR ocarina_processors_x86::x86.linux {
Taste::coordinates => "96060 48818 123338 78530";
};
generic_sockets_ip_pohic : DEVICE deploymentview::DV::Node1::generic_sockets_ip_pohic.others {
Taste::coordinates => "98530 80423 114403 88536";
};
CONNECTIONS
generic_sockets_ip_pohic_ip_i_link : BUS ACCESS generic_sockets_ip_pohic_ip_i -> generic_sockets_ip_pohic.link;
PROPERTIES
Taste::APLC_Binding => (reference (first_binary)) APPLIES TO IV_Level0_Appear;
Actual_Processor_Binding => (reference (x86_linux)) APPLIES TO first_binary;
Actual_Processor_Binding => (reference (x86_linux)) APPLIES TO generic_sockets_ip_pohic;
END Node1.others;
SYSTEM Node2
FEATURES
generic_sockets_ip_pohic_ip_i : REQUIRES BUS ACCESS ocarina_buses::ip.i;
END Node2;
SYSTEM IMPLEMENTATION Node2.others
SUBCOMPONENTS
IV_Nested1_Appear : SYSTEM interfaceview::IV::Function1_ShouldNotAppear::Nested1_Appear::Nested1_Appear.others {
Taste::FunctionName => "Nested1_Appear";
};
IV_Nested2_Appear : SYSTEM interfaceview::IV::Function1_ShouldNotAppear::Should_Not_Appear_Either::Nested2_Appear::Nested2_Appear.others {
Taste::FunctionName => "Nested2_Appear";
};
IV_MotherClass_Appear : SYSTEM interfaceview::IV::Function1_ShouldNotAppear::MotherClass_Appear::MotherClass_Appear.others {
Taste::FunctionName => "MotherClass_Appear";
};
IV_Z_Shown : SYSTEM interfaceview::IV::Y_Hidden::Z_Shown::Z_Shown.others {
Taste::FunctionName => "Z_Shown";
};
second_binary : PROCESS deploymentview::DV::Node2::second_binary.others {
Taste::coordinates => "158753 54524 184337 75323";
Deployment::Port_Number => 0;
};
x86_linux : PROCESSOR ocarina_processors_x86::x86.linux {
Taste::coordinates => "155555 48582 187535 78294";
};
generic_sockets_ip_pohic : DEVICE deploymentview::DV::Node2::generic_sockets_ip_pohic.others {
Taste::coordinates => "165431 80070 178599 88889";
};
CONNECTIONS
generic_sockets_ip_pohic_ip_i_link : BUS ACCESS generic_sockets_ip_pohic_ip_i -> generic_sockets_ip_pohic.link;
PROPERTIES
Taste::APLC_Binding => (reference (second_binary)) APPLIES TO IV_Nested1_Appear;
Taste::APLC_Binding => (reference (second_binary)) APPLIES TO IV_Nested2_Appear;
Taste::APLC_Binding => (reference (second_binary)) APPLIES TO IV_MotherClass_Appear;
Taste::APLC_Binding => (reference (second_binary)) APPLIES TO IV_Z_Shown;
Actual_Processor_Binding => (reference (x86_linux)) APPLIES TO second_binary;
Actual_Processor_Binding => (reference (x86_linux)) APPLIES TO generic_sockets_ip_pohic;
END Node2.others;
SYSTEM deploymentview SYSTEM deploymentview
END deploymentview; END deploymentview;
SYSTEM IMPLEMENTATION deploymentview.others SYSTEM IMPLEMENTATION deploymentview.others
SUBCOMPONENTS SUBCOMPONENTS
Node1 : SYSTEM Node1.others {
Taste::coordinates => "93944 47854 128042 90299";
};
Node2 : SYSTEM Node2.others {
Taste::coordinates => "152498 47148 192474 89594";
};
ip_i : BUS ocarina_buses::ip.i {
Taste::coordinates => "118165 102645 173427 113227";
};
interfaceview : SYSTEM interfaceview::IV::interfaceview.others; interfaceview : SYSTEM interfaceview::IV::interfaceview.others;
CONNECTIONS
Connection2 : BUS ACCESS ip_i -> Node1.generic_sockets_ip_pohic_ip_i {
Taste::coordinates => "110053 88536 110053 95590 123691 95590 123691 102645";
};
Connection1 : BUS ACCESS ip_i -> Node2.generic_sockets_ip_pohic_ip_i {
Taste::coordinates => "165431 84480 158141 84480 158141 102645";
};
PROPERTIES
Actual_Connection_Binding => (reference (ip_i)) APPLIES TO interfaceview.Function1_ShouldNotAppear_PI_hello_Level0_Appear_RI_I_say_hello;
Actual_Connection_Binding => (reference (ip_i)) APPLIES TO interfaceview.Level0_Appear_PI_final_result_Function1_ShouldNotAppear_RI_my_final_result;
END deploymentview.others; END deploymentview.others;
PROPERTIES PROPERTIES
Taste::coordinates => "0 0 297000 210000"; Taste::coordinates => "0 0 297000 210000";
Taste::version => "2.0"; Taste::version => "2.0";
Taste::interfaceView => "InterfaceView.aadl"; Taste::interfaceView => "InterfaceView.aadl";
Taste::HWLibraries => ("../../tool-inst/share/ocarina/AADLv2/ocarina_components.aadl"); Taste::HWLibraries => ("../../../tool-inst/share/ocarina/AADLv2/ocarina_components.aadl");
END deploymentview::DV; END deploymentview::DV;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment