------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2020, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, 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$ -- $Date$ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Translate; use Translate; with Objects; use Objects; with Objects.extended; use Objects.extended; with unbounded_strings; use unbounded_strings; with initialize_framework; use initialize_framework; with Debug; use Debug; package body battery_Set is procedure Add_battery (My_batteries : in out batteries_Set; Name : in Unbounded_String; cpu_Name : in Unbounded_String; Capacity : in Integer; e_max : in Integer; initial_energy : in integer; Rechargeable_Power : in Integer) is Dummy : battery_Ptr; begin Add_battery (My_batteries, Dummy, Name, cpu_name, Capacity, e_max, initial_energy, Rechargeable_Power); end Add_battery; procedure Check_battery (My_batteries : in batteries_Set; Name : in Unbounded_String; cpu_Name : in Unbounded_String; Capacity : in Integer; e_max : in Integer; initial_energy : in integer; Rechargeable_Power : in Integer) is begin if (Name = "") then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery_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_battery (Current_Language) & " " & Name & " : " & Lb_battery_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; if (cpu_Name = "") then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : " & Lb_processor_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (cpu_Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (lb_battery(Current_Language) & Name & " : " & lb_processor_name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; if (Rechargeable_Power <= 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : " & Lb_Rechargeable_Power(Current_Language) & Lb_Must_Be (Current_Language) & Lb_greater_than (Current_Language) & "0")); end if; if (initial_energy<= 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : initial_energy " & Lb_Must_Be (Current_Language) & Lb_greater_than (Current_Language) & "0")); end if; if (e_max<= 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : e_max " & Lb_Must_Be (Current_Language) & Lb_greater_than (Current_Language) & "0")); end if; if (Capacity <= 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : " & Lb_Capacity (Current_Language) & Lb_Must_Be (Current_Language) & Lb_greater_than (Current_Language) & "0")); end if; end Check_battery; procedure Add_battery (My_batteries : in out batteries_Set; A_battery : in out battery_Ptr; Name : in Unbounded_String; cpu_Name : in Unbounded_String; Capacity : in Integer; e_max : in Integer; initial_energy : in integer; Rechargeable_Power : in Integer) is My_Iterator : iterator; begin Check_Initialize; Check_battery (My_batteries, Name, cpu_name, Capacity, e_max, initial_energy, Rechargeable_Power); if (get_number_of_elements (My_batteries) > 0) then reset_iterator (My_batteries, My_Iterator); loop current_element (My_batteries, A_battery, My_Iterator); if (Name = A_battery.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_battery (Current_Language) & " " & Name & " : " & Lb_battery_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_batteries, My_Iterator); next_element (My_batteries, My_Iterator); end loop; end if; A_battery:=new battery; A_battery.name:=Name; A_battery.cpu_name:=cpu_Name; A_battery.Capacity:=Capacity; A_battery.e_max:=e_max; A_battery.initial_energy:=initial_energy; A_battery.Rechargeable_Power:= Rechargeable_Power; add (My_batteries, A_battery); exception when full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_batteries (Current_Language))); end Add_battery; end battery_Set;