Commit ddd7046f authored by julien.delange's avatar julien.delange
Browse files

* Add the SEQUENCE ASN1 type definition

 * update Headers with ESA name



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@686 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent b6107aa7
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -52,6 +52,7 @@ package body Ocarina.Backends.ASN1.Deployment is
use Ocarina.Backends.ASN1_Tree.Nutils;
package ASN1N renames Ocarina.Backends.ASN1_Tree.Nodes;
package ASN1U renames Ocarina.Backends.ASN1_Tree.Nutils;
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
procedure Visit_Architecture_Instance (E : Node_Id);
......@@ -76,6 +77,12 @@ package body Ocarina.Backends.ASN1.Deployment is
-- ports used in the distributed system. In fact, we add each
-- port in an enumeration and associate a value to them.
Packet_Type : Node_Id;
-- The Packet_Type node contains the definition of a packet
-- sent by a node. It consists of a sender-thread/port id, the
-- receiver thread/port id, and a message that is expressed
-- using an ASN1 CHOICE.
Port_Id : Unsigned_Long_Long := 0;
-- The port identifier. This is unique for each port.
......@@ -121,7 +128,7 @@ package body Ocarina.Backends.ASN1.Deployment is
if Length (Thread_Enumeration) > 0 then
Append_Node_To_List
(Make_Type_Definition
(Get_String_Name ("THREADS"),
(Get_String_Name ("THREAD-ID"),
Make_Enumerated (Thread_Enumeration)),
ASN1N.Definitions (Module_Node));
end if;
......@@ -129,11 +136,46 @@ package body Ocarina.Backends.ASN1.Deployment is
if Length (Thread_Enumeration) > 0 then
Append_Node_To_List
(Make_Type_Definition
(Get_String_Name ("PORTS"),
(Get_String_Name ("PORT-ID"),
Make_Enumerated (Port_Enumeration)),
ASN1N.Definitions (Module_Node));
end if;
declare
Pkt_Contents : constant List_Id := ASN1U.New_List (ASN1N.K_List_Id);
begin
Append_Node_To_List
(Make_Sequence_Member
(Get_String_Name ("sender-thread"),
Get_String_Name ("THREAD-ID")),
Pkt_Contents);
Append_Node_To_List
(Make_Sequence_Member
(Get_String_Name ("sender-port"),
Get_String_Name ("PORT-ID")),
Pkt_Contents);
Append_Node_To_List
(Make_Sequence_Member
(Get_String_Name ("receiver-thread"),
Get_String_Name ("THREAD-ID")),
Pkt_Contents);
Append_Node_To_List
(Make_Sequence_Member
(Get_String_Name ("receiver-port"),
Get_String_Name ("PORT-ID")),
Pkt_Contents);
Packet_Type :=
Make_Type_Definition
(Get_String_Name ("PKT"),
Make_Sequence (Pkt_Contents));
Append_Node_To_List
(Packet_Type, ASN1N.Definitions (Module_Node));
end;
end Visit_Architecture_Instance;
------------------------------
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -58,6 +58,8 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
procedure Generate_Type_Definition (N : Node_Id);
procedure Generate_Enumerated (N : Node_Id);
procedure Generate_Enumerated_Value (N : Node_Id);
procedure Generate_Sequence (N : Node_Id);
procedure Generate_Sequence_Member (N : Node_Id);
-----------
-- Write --
......@@ -100,6 +102,12 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
when K_Enumerated_Value =>
Generate_Enumerated_Value (N);
when K_Sequence =>
Generate_Sequence (N);
when K_Sequence_Member =>
Generate_Sequence_Member (N);
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
......@@ -194,4 +202,36 @@ package body Ocarina.Backends.ASN1_Tree.Generator is
end if;
end Generate_Enumerated_Value;
-----------------------
-- Generate_Sequence --
-----------------------
procedure Generate_Sequence (N : Node_Id) is
P : Node_Id;
begin
Write_Line (" SEQUENCE {");
if not Is_Empty (Values (N)) then
P := First_Node (Values (N));
while Present (P) loop
Generate (P);
P := Next_Node (P);
if P /= No_Node then
Write_Char (',');
end if;
end loop;
end if;
Write_Line ("}");
end Generate_Sequence;
------------------------------
-- Generate_Sequence_Member --
------------------------------
procedure Generate_Sequence_Member (N : Node_Id) is
begin
Write_Name (Member_Name (N));
Write_Space;
Write_Name (Member_Type (N));
end Generate_Sequence_Member;
end Ocarina.Backends.ASN1_Tree.Generator;
......@@ -74,6 +74,17 @@ module Ocarina::Backends::ASN1_Tree::Nodes {
Value_Id Value;
};
interface Sequence : Node_Id
{
List_Id Values;
};
interface Sequence_Member : Node_Id
{
Name_Id Member_Name;
Name_Id Member_Type;
};
interface Literal : Node_Id {
Value_Id Value;
};
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -536,6 +536,34 @@ package body Ocarina.Backends.ASN1_Tree.Nutils is
return N;
end Make_Enumerated;
-------------------
-- Make_Sequence --
-------------------
function Make_Sequence (Sequence_Members : List_Id) return Node_Id
is
N : Node_Id;
begin
N := New_Node (K_Sequence);
Set_Values (N, Sequence_Members);
return N;
end Make_Sequence;
--------------------------
-- Make_Sequence_Member --
--------------------------
function Make_Sequence_Member
(Member_Name : Name_Id; Member_Type : Name_Id) return Node_Id
is
N : Node_Id;
begin
N := New_Node (K_Sequence_Member);
Set_Member_Name (N, Member_Name);
Set_Member_Type (N, Member_Type);
return N;
end Make_Sequence_Member;
------------------
-- Make_Literal --
------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -195,4 +195,12 @@ package Ocarina.Backends.ASN1_Tree.Nutils is
-- Make a Literal that contains a value (Value-Id), see
-- Ocarina.Backends.ASN1_Values for more information.
function Make_Sequence (Sequence_Members : List_Id) return Node_Id;
-- Make a sequence that contains the members given in parameter.
function Make_Sequence_Member
(Member_Name : Name_Id; Member_Type : Name_Id) return Node_Id;
-- Make a sequence member identified by Member_Name which has the
-- type Member_Type.
end Ocarina.Backends.ASN1_Tree.Nutils;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2008, GET-Telecom Paris. --
-- Copyright (C) 2006-2010, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -135,7 +135,7 @@ procedure Headers_Ocarina is
Last := Range_Image'First + 3;
end if;
return "Copyright (C) " & Range_Image (Range_Image'First .. Last)
& ", GET-Telecom Paris.";
& ", European Space Agency (ESA).";
end Copyright_Line;
-----------------
......
Markdown is supported
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