------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with unbounded_strings; use unbounded_strings; with Ada.Exceptions; use Ada.Exceptions; with Translate; use Translate; with initialize_framework; use initialize_framework; with objects.extended; use objects.extended; package body Network_Set is procedure Check_network (My_networks : in Networks_Set; Name : in Unbounded_String; Network_Type : in Networks_architecture_Type; Network_Delay : in Networks_Delay_Type := bounded_delay; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is begin if Name = "" then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Network_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : " & Lb_network_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; end Check_network; procedure Add_Network (My_Networks : in out Networks_Set; Name : in Unbounded_String; Network_Type : in Networks_architecture_Type; Network_Delay : in Networks_Delay_Type := bounded_delay; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is dummy : generic_network_ptr; begin add_network(my_networks, dummy, name, network_type, network_delay, Routing_Protocol, Processor_Positions); end add_network; procedure Add_Network (My_Networks : in out Networks_Set; a_network : out generic_network_ptr; Name : in Unbounded_String; Network_Type : in Networks_architecture_Type; Network_Delay : in Networks_Delay_Type := bounded_delay; Routing_Protocol : in Routing_Type := XY; Processor_Positions : in Positions_Table := No_Position) is My_Iterator : iterator; New_NOC_Network : NOC_network_ptr; New_Bus_Network : Bus_network_ptr; begin check_initialize; Check_network (My_Networks, Name, Network_Type, network_delay, Routing_Protocol, Processor_Positions); if (get_number_of_elements (My_Networks) > 0) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); if (Name = A_Network.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_network (Current_Language) & " " & Name & " : " & Lb_network_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_Networks, My_Iterator); next_element (My_Networks, My_Iterator); end loop; end if; case network_Type is when Bus | Star | Link => New_Bus_Network:= new Bus_network; A_Network := Generic_Network_Ptr (New_Bus_Network); when NOC => New_NOC_Network:= new NOC_network; New_Noc_Network.Routing_Protocol:= Routing_Protocol; New_Noc_Network.Processor_Positions:= Processor_Positions; A_Network := Generic_Network_Ptr (New_NOC_Network); end case; A_Network.name := Name; A_Network.network_architecture_type := Network_Type; add (My_Networks, A_Network); exception when Generic_Network_Set.full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Networks (Current_Language))); end Add_Network; procedure Update_Network (My_Networks : in out Networks_Set; Name : in Unbounded_String; Network_Type : in Networks_architecture_Type) is A_Network : generic_Network_Ptr; begin A_Network := Search_Network (My_Networks, Name); delete (My_Networks, A_Network); Add_Network (My_Networks, Name, network_type); end Update_Network; function Search_Network (My_Networks : in Networks_Set; Name : in Unbounded_String) return generic_Network_Ptr is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : generic_Network_Ptr; Found : Boolean := False; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); if (A_Network.name = Name) then Found := True; Result := A_Network; end if; exit when is_last_element (My_Networks, My_Iterator); next_element (My_Networks, My_Iterator); end loop; end if; if not Found then Raise_Exception (network_not_found'Identity, to_string(lb_name(current_language) & " = " & name) ); end if; return Result; end Search_Network; function Export_Aadl_Implementations (My_Networks : in Networks_Set) return Unbounded_String is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : Unbounded_String := empty_string; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); exit when is_last_element (My_Networks, My_Iterator); Result := Result & To_Unbounded_String ("bus " & To_String (A_Network.name)); Result := Result & To_Unbounded_String ("end " & To_String (A_Network.name) & ";"); Result := Result & To_Unbounded_String ("bus implementation " & To_String (A_Network.name) & ".Impl"); Result := Result & To_Unbounded_String ("end " & To_String (A_Network.name) & ".Impl"); next_element (My_Networks, My_Iterator); end loop; end if; return Result; end Export_Aadl_Implementations; function Export_Aadl_Declarations (My_Networks : in Networks_Set; Number_Of_Ht : in Natural) return Unbounded_String is My_Iterator : iterator; A_Network : generic_Network_Ptr; Result : Unbounded_String := empty_string; begin if not is_empty (My_Networks) then reset_iterator (My_Networks, My_Iterator); loop current_element (My_Networks, A_Network, My_Iterator); exit when is_last_element (My_Networks, My_Iterator); for I in 1 .. Number_Of_Ht loop Result := Result & ASCII.HT; end loop; Result := Result & To_Unbounded_String ("instancied_" & To_String (A_Network.name) & " : bus " & To_String (A_Network.name) & ".Impl;"); next_element (My_Networks, My_Iterator); end loop; end if; return Result; end Export_Aadl_Declarations; end Network_Set;