with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with GNAT.Os_Lib; with Objects; use Objects; with Memories; use Memories; use Memories.Memories_Table_Package; with Memory_set; use Memory_set; with Tasks; use Tasks; with Task_Set; use Task_Set; with Systems; use Systems; with Processors; use Processors; with Processor_Set; use Processor_Set; with Address_Spaces; use Address_Spaces; with Address_Space_Set; use Address_Space_Set; with Core_Units; use Core_Units; use Core_Units.Core_Units_Table_Package; with batteries; use batteries; with battery_set; use battery_set; with Processor_Interface; use Processor_Interface; with Scheduler_Interface; use Scheduler_Interface; with Random_Tools; use Random_Tools; with architecture_factory; use architecture_factory; with unbounded_strings; use unbounded_strings; with call_framework; use call_framework; with feasibility_test.feasibility_interval; use feasibility_test.feasibility_interval; with doubles; use doubles; with priority_assignment.rm; use priority_assignment.rm; with Ada.Numerics; with Ada.Numerics.Float_Random; procedure Generate_amp_icq_multicore is sys : System; a_core : Core_Unit_Ptr; a_processor : Generic_Processor_Ptr; a_core_unit_table : Core_Units_Table; my_tasks : tasks_set; first_core : Boolean := True; current_core : Unbounded_String; processor_name : Unbounded_String := To_Unbounded_String("processor1"); addr_name : Unbounded_String := To_Unbounded_String("addr1"); File : File_Type; Line : String(1 .. 255); Last : Natural; type String_Array is array (1 .. 9) of Unbounded_String; function Process_Rec(Line : String) return String_Array is Fields : String_Array; Sep_Pos : Natural := 0; Field_Index : Natural := 1; Trimmed_Line : String := Trim(Line, Ada.Strings.Both); begin -- Découpe la ligne selon ';' for I in Trimmed_Line'Range loop if Trimmed_Line(I) = ';' then Fields(Field_Index) := To_Unbounded_String(Trim(Trimmed_Line(Sep_Pos + 1 .. I - 1), Ada.Strings.Both)); Sep_Pos := I; Field_Index := Field_Index + 1; exit when Field_Index > 9; end if; end loop; -- Dernier champ (si la ligne ne se termine pas par ';') if Field_Index <= 9 then Fields(Field_Index) := To_Unbounded_String(Trim(Trimmed_Line(Sep_Pos + 1 .. Trimmed_Line'Last), Ada.Strings.Both)); end if; return Fields; end Process_Rec; begin -- Vérifie qu'un argument a été passé if Argument_Count < 1 then Put ("Usage: " & Command_Name & " "); Put_Line ("Filename"); GNAT.OS_Lib.OS_Exit (1); end if; -- Récupère le nom du fichier depuis les arguments declare File_Name : String := Argument(1); begin Open(File, In_File, File_Name); exception when others => Put_Line("Erreur : Impossible d'ouvrir le fichier " & File_Name); return; end; -- Lecture du fichier while not End_Of_File(File) loop Get_Line(File, Line, Last); declare Trimmed : String := Trim(Line(1 .. Last), Ada.Strings.Both); Extracted_Fields : String_Array := Process_Rec(Trimmed); begin -- Ignorer les lignes vides ou les titres if Trimmed'Length > 0 and then Trimmed /= "Taskset 1" and then Trimmed /= "core0" then -- Traiter les enregistrements declare field1 : String := To_String(Extracted_Fields(1)); field2 : String := To_String(Extracted_Fields(2)); field3 : String := To_String(Extracted_Fields(3)); field4 : String := To_String(Extracted_Fields(4)); field5 : String := To_String(Extracted_Fields(5)); field6 : String := To_String(Extracted_Fields(6)); field7 : String := To_String(Extracted_Fields(7)); field8 : String := To_String(Extracted_Fields(8)); -- Affichage des valeurs extraites begin if field1'Length >= 4 and field1(1..4)="core" then Put_Line("Create a core"); current_core := to_unbounded_string(field1); if first_core = True then first_core := False; Call_Framework.initialize (False); Initialize (sys); else Add_core_unit (sys.Core_units, a_core, current_core, preemptive, 0, 1, 0, 0, 0, To_Unbounded_String (""), To_Unbounded_String (""), Posix_1003_Highest_Priority_First_Protocol, no_memories, empty_string, empty_string, 0, 0); Add (a_core_unit_table, a_core); end if; else Put_Line("Create a task"); Add_Task (my_tasks => my_tasks, name => to_unbounded_string((field1)), cpu_name => processor_name, address_space_name => addr_name, core_name => current_core, task_type => Periodic_Type, start_time => Integer'Value(field5), capacity => 10, --A préciser period => Integer'Value(field3), deadline => Integer'Value(field4), jitter => 0, blocking_time => 0, priority => Integer'Value(field2), criticality => 0, policy => sched_fifo); end if; end; end if; end; end loop; Close(File); Add_Processor (my_processors => sys.Processors, a_processor => a_processor, name => processor_name, cores => A_Core_Unit_Table, a_migration => No_Migration_Type, a_processor_type => IDENTICAL_MULTICORES_TYPE); Add_Address_Space (sys.Address_Spaces, addr_name, processor_name, 0, 0, 0, 0); sys.tasks := my_tasks; declare File_Name : String := Argument(1)(1 .. Argument(1)'Length - 4) & ".xmlv3"; begin write_to_xml_file(sys, File_Name); end; ------ end Generate_amp_icq_multicore;