------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2010, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- the LISyC Team, University of Western Britanny. -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- 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: 423 $ -- $Date: 2011-04-21 01:38:29 +0200 (jeu., 21 avr. 2011) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Sax.Readers; use Sax.Readers; with Sax.Exceptions; use Sax.Exceptions; with Sax.Locators; use Sax.Locators; with Sax.Attributes; use Sax.Attributes; with Unicode.CES; use Unicode.CES; with Unicode; use Unicode; with Offsets; use Offsets; use Offsets.Offsets_Table_package; with Parameters; use Parameters; use Parameters.User_Defined_Parameters_Table_Package; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Strings; use Strings; with Unbounded_Strings; use Unbounded_Strings; with Dependencies; use Dependencies; with Resources; use Resources; use Resources.resource_accesses; with Resource_Set; use Resource_Set; use Resource_Set.Generic_Resource_Set; with Messages; use Messages; with Message_Set; use Message_Set; use Message_Set.Generic_Message_Set; with Event_Analyzer_Set; use Event_Analyzer_Set; use Event_Analyzer_Set.Generic_Event_Analyzer_Set; with Tasks; use Tasks; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Address_Space_Set; use Address_Space_Set; use Address_Space_Set.Generic_Address_Space_Set; with Buffers; use Buffers; use Buffers.Buffer_Roles_package; with Buffer_Set; use Buffer_Set; use Buffer_Set.Generic_Buffer_Set; with Processors; use Processors; with core_units; use core_units; use core_units.Core_Units_Table_Package; with Queueing_Systems; use Queueing_Systems; with Time_Unit_events; use Time_Unit_events; use Time_Unit_events.Time_Unit_Package; with Scheduling_analysis; use Scheduling_analysis; with Scheduler_interface; use Scheduler_interface; with Task_Dependencies; use Task_Dependencies; with Network_Set; use Network_Set; with Ada.Strings.Maps; use Ada.Strings.Maps; with Networks; use Networks; with framework_config; use framework_config; package body v2_Xml_Parsers is ------------------------------------------------------------- ------------------------------------------------------------- -- Generic XML parser ------------------------------------------------------------- ------------------------------------------------------------- -- Status information (store parameters of each tag) -- Current_Parameter : Integer; Max_Xml_Tag_Parameters : constant Natural := 10000; Parameter_List : array (1 .. Max_Xml_Tag_Parameters) of Unbounded_String; procedure Characters (Handler : in out Xml_Generic_Parser; Ch : Unicode.CES.Byte_Sequence) is -- A pair of index objects to keep track of the beginning and -- ending of the tokens isolated from the string -- First : Natural; Last : Positive; index : Positive; find_first_space : Boolean; -- A character set consisting of the "whitespace" characters -- that separate the tokens: -- Whitespace : constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set (" "); -- The string to split -- The_Line : Unbounded_String; begin -- suppress extra blank and unprintable characters before splitting --parameters -- find_first_space := False; index := Ch'First; while index <= Ch'Last loop if (Ch (index) /= ASCII.CR) and (Ch (index) /= ASCII.LF) and (Ch (index) /= ASCII.HT) then if (Ch (index) = ' ') then if (not find_first_space) then The_Line := The_Line & Ch (index); end if; find_first_space := True; else The_Line := The_Line & Ch (index); find_first_space := False; end if; end if; index := index + 1; end loop; -- Remove blank in the beginnning/end of the string -- if Slice (The_Line, 1, 1) = " " then The_Line := To_Unbounded_String (Slice (The_Line, 2, Length (The_Line))); end if; if Slice (The_Line, Length (The_Line), Length (The_Line)) = " " then The_Line := To_Unbounded_String (Slice (The_Line, 1, Length (The_Line) - 1)); end if; -- Split parameters -- loop Find_Token (The_Line, Set => Whitespace, Test => Ada.Strings.Outside, First => First, Last => Last); Parameter_List (Current_Parameter) := To_Unbounded_String (Slice (The_Line, First, Last)); Current_Parameter := Current_Parameter + 1; The_Line := To_Unbounded_String (Slice (The_Line, Last + 1, Length (The_Line))); exit when Length (The_Line) = 0; end loop; end Characters; procedure Warning (Handler : in out Xml_Generic_Parser; Except : Sax.Exceptions.Sax_Parse_Exception'Class) is begin Put_Line ("Xml warning (" & Get_Message (Except) & ", at " & To_String (Get_Location (Except)) & ')'); end Warning; procedure Error (Handler : in out Xml_Generic_Parser; Except : Sax.Exceptions.Sax_Parse_Exception'Class) is begin Put_Line ("Xml parser error (" & Get_Message (Except) & ", at " & To_String (Get_Location (Except)) & ')'); end Error; procedure Fatal_Error (Handler : in out Xml_Generic_Parser; Except : Sax.Exceptions.Sax_Parse_Exception'Class) is begin Put_Line ("Xml parser fatal error (" & Get_Message (Except) & ')'); Fatal_Error (Reader (Handler), Except); end Fatal_Error; ------------------------------------------------------------- ------------------------------------------------------------- -- XML project file parser ------------------------------------------------------------- ------------------------------------------------------------- -- Information retrieved from the xml parser -- Name : Unbounded_String; X, Y : Natural; Deadline : Integer; Start_Time : Integer; Blocking_Time : Integer; State : Integer; address : Integer; Period : Integer; Context_Switch_Overhead : Integer; Criticality : Integer; Capacity : Integer; Cpu_Name : Unbounded_String; Address_Space_Name : Unbounded_String; Jitter : Natural; Policy : Policies; Task_Type : Tasks_Type; Parametric_Rule : Unbounded_String; Automaton_Name : Unbounded_String; Seed : Integer; Predictable : Boolean; Quantum : Integer; Priority : Integer; priority_assignment : Priority_Assignment_Type; A_Scheduler : Schedulers_Type; a_network_protocol : Networks_Type; A_Network : Unbounded_String; a_core : core_unit_ptr; Size : Natural; Protocol : Resources_Type; Is_Preemptive : Preemptives_Type; File_Name : Unbounded_String; Response_Time : Natural; Communication_Time : Natural; A_Qs : Queueing_Systems_Type; Text_Memory_Size : Integer; Heap_Memory_Size : Integer; Data_Memory_Size : Integer; Stack_Memory_Size : Integer; Roles : Buffer_Roles_Table; A_Role : Buffer_Role; Offset : Offsets_Table; A_Offset : Offset_Type; A_Task_Lists_Entry : critical_section; A_Task_Lists : resource_accesses_Table; Param : User_Defined_Parameters_Table; A_Param : Parameter_ptr; From_Type : Unbounded_String; To_Type : Unbounded_String; Ok : Boolean; -- Initialize all data -- procedure Initialize_Project_Parser (Handler : in out Xml_Project_Parser) is begin Current_Parameter := 1; X := 0; Y := 0; State := 0; address := 0; Task_Type := Aperiodic_Type; Parametric_Rule := To_Unbounded_String (""); Automaton_Name := To_Unbounded_String (""); Seed := 0; Predictable := True; Priority := 1; priority_assignment := Automatic_Assignment; Name := To_Unbounded_String (""); Deadline := 0; Criticality := 0; Period := 0; Context_Switch_Overhead := 0; Protocol := No_Protocol; Cpu_Name := To_Unbounded_String (""); Address_Space_Name := To_Unbounded_String (""); Jitter := 0; Initialize (Offset); Initialize (Param); Quantum := 0; A_Scheduler := No_Scheduling_Protocol; A_Network := To_Unbounded_String (""); Is_Preemptive := Preemptive; File_Name := To_Unbounded_String (""); Size := 0; Initialize (Roles); A_Role.The_Role := queuing_Consumer; Initialize (A_Task_Lists_Entry); Initialize (A_Task_Lists); Text_Memory_Size := 0; Heap_Memory_Size := 0; Data_Memory_Size := 0; Stack_Memory_Size := 0; A_Qs := Qs_Mm1; end Initialize_Project_Parser; procedure Start_Document (Handler : in out Xml_Project_Parser) is begin Initialize_Project_Parser (Handler); Initialize (Handler.Parsed_System); end Start_Document; procedure Start_Element (Handler : in out Xml_Project_Parser; Namespace_Uri : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := ""; Atts : Sax.Attributes.Attributes'Class) is begin Current_Parameter := 1; -- Store attributes -- if Get_Length (Atts) > 0 then if Qname = "scheduler" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "quantum" then To_Integer (Get_Value (Atts, J), Quantum, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "is_preemptive" then To_Preemptives_type (Get_Value (Atts, J), Is_Preemptive, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "parametric_file_name" then File_Name := To_Unbounded_String (Get_Value (Atts, J)); end if; if Get_Qname (Atts, J) = "automaton_name" then Automaton_Name := To_Unbounded_String (Get_Value (Atts, J)); end if; end loop; else if Qname = "task" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "task_type" then To_Tasks_Type (Get_Value (Atts, J), Task_Type, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "x" then To_Natural (Get_Value (Atts, J), X, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "y" then To_Natural (Get_Value (Atts, J), Y, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; end loop; else if Qname = "event_analyzer" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "parametric_file_name" then File_Name := To_Unbounded_String (Get_Value (Atts, J)); end if; end loop; else if Qname = "buffer" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "x" then To_Natural (Get_Value (Atts, J), X, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "y" then To_Natural (Get_Value (Atts, J), Y, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; end loop; else if Qname = "message" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "x" then To_Natural (Get_Value (Atts, J), X, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Get_Qname (Atts, J) = "y" then To_Natural (Get_Value (Atts, J), Y, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; end loop; else if Qname = "buffer_user" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "buffer_role" then if (Get_Value (Atts, J) /= "consumer") and (Get_Value (Atts, J) /= "producer") then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; if Get_Value (Atts, J) = "consumer" then A_Role.The_Role := queuing_Consumer; else A_Role.The_Role := queuing_Producer; end if; end if; end loop; else if Qname = "parameter" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "parameter_type" then if (Get_Value (Atts, J) /= "integer") and (Get_Value (Atts, J) /= "double") and (Get_Value (Atts, J) /= "string") and (Get_Value (Atts, J) /= "boolean") then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; if Get_Value (Atts, J) = "integer" then A_Param := new Parameter (Integer_Parameter); end if; if Get_Value (Atts, J) = "boolean" then A_Param := new Parameter (Boolean_Parameter); end if; if Get_Value (Atts, J) = "string" then A_Param := new Parameter (String_Parameter); end if; if Get_Value (Atts, J) = "double" then A_Param := new Parameter (Double_Parameter); end if; end if; end loop; else if Qname = "dependency" then for J in 0 .. Get_Length (Atts) - 1 loop if Get_Qname (Atts, J) = "from_type" then if (Get_Value (Atts, J) /= "buffer") and (Get_Value (Atts, J) /= "message") and (Get_Value (Atts, J) /= "task") then Put_Line ( "Warning : Error on data type. From " & To_String (Handler.Locator)); end if; From_Type := To_Unbounded_String (Get_Value (Atts, J)); end if; if Get_Qname (Atts, J) = "to_type" then if (Get_Value (Atts, J) /= "buffer") and (Get_Value (Atts, J) /= "message") and (Get_Value (Atts, J) /= "task") then Put_Line ( "Warning : Error on data type. From " & To_String (Handler.Locator)); end if; To_Type := To_Unbounded_String (Get_Value (Atts, J)); end if; end loop; end if; end if; end if; end if; end if; end if; end if; end if; end if; end Start_Element; procedure End_Element (Handler : in out Xml_Project_Parser; Namespace_Uri : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := "") is Buff_Iterator : Buffers_Iterator; Mess_Iterator : Messages_Iterator; A_Buff : Buffer_Ptr; A_Mess : Generic_Message_Ptr; Task1, Task2 : Generic_Task_Ptr; begin ----------------------------------- -- Element with one parameter ----------------------------------- if Qname = "name" then Name := Parameter_List (1); end if; if Qname = "address_space_name" then Address_Space_Name := Parameter_List (1); end if; if Qname = "cpu_name" then Cpu_Name := Parameter_List (1); end if; if Qname = "network_link" then A_Network := Parameter_List (1); end if; if Qname = "scheduler" then To_Schedulers_type (Parameter_List (1), A_Scheduler, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "activation_rule" then Parametric_Rule := Parameter_List (1); end if; if Qname = "period" then To_Integer (Parameter_List (1), Period, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "context_switch_overhead" then To_Integer (Parameter_List (1), Context_Switch_Overhead, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "size" then To_Natural (Parameter_List (1), Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "criticality" then To_Integer (Parameter_List (1), Criticality, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "response_time" then To_Natural (Parameter_List (1), Response_Time, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "communication_time" then To_Natural (Parameter_List (1), Communication_Time, Ok); if not Ok then Put_Line ("warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "deadline" then To_Integer (Parameter_List (1), Deadline, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "state" then To_Integer (Parameter_List (1), State, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "seed" then To_Integer (Parameter_List (1), Seed, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "predictable_seed" then To_Boolean (Parameter_List (1), Predictable, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "protocol" then To_Resources_Type (Parameter_List (1), Protocol, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "priority_assignment" then To_Priority_Assignment_Type (Parameter_List (1), Priority_Assignment, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "qs" then To_Queueing_Systems_Type (Parameter_List (1), A_Qs, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "policy" then To_Policies (Parameter_List (1), Policy, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "jitter" then To_Integer (Parameter_List (1), Jitter, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "capacity" then To_Integer (Parameter_List (1), Capacity, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "priority" then To_Integer (Parameter_List (1), Priority, Ok); if not Ok then Priority := 1; Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "start_time" then To_Integer (Parameter_List (1), Start_Time, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "blocking_time" then To_Integer (Parameter_List (1), Blocking_Time, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "text_memory_size" then To_Integer (Parameter_List (1), Text_Memory_Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "heap_memory_size" then To_Integer (Parameter_List (1), Heap_Memory_Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "data_memory_size" then To_Integer (Parameter_List (1), Data_Memory_Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if Qname = "stack_memory_size" then To_Integer (Parameter_List (1), Stack_Memory_Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; ----------------------------------- -- Element with several parameters ----------------------------------- if Qname = "resource_user" then To_Natural (Parameter_List (2), A_Task_Lists_Entry.Task_Begin, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; To_Natural (Parameter_List (3), A_Task_Lists_Entry.Task_End, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Add (A_Task_Lists, Parameter_List (1), A_Task_Lists_Entry); end if; if Qname = "buffer_user" then To_Natural (Parameter_List (2), A_Role.Size, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; To_Natural (Parameter_List (3), A_Role.Time, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Add (Roles, Parameter_List (1), A_Role); end if; if Qname = "offset" then To_Natural (Parameter_List (1), A_Offset.Activation, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; To_Natural (Parameter_List (2), A_Offset.Offset_Value, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Add (Offset, A_Offset); end if; if Qname = "parameter" then A_Param.parameter_Name := Parameter_List (2); if A_Param.type_of_parameter = String_Parameter then A_Param.string_value := Parameter_List (1); end if; if A_Param.type_of_parameter = Boolean_Parameter then To_Boolean (Parameter_List (1), A_Param.Boolean_value, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if A_Param.type_of_parameter = Integer_Parameter then To_Integer (Parameter_List (1), A_Param.Integer_value, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; if A_Param.type_of_parameter = Double_Parameter then To_Double (Parameter_List (1), A_Param.double_value, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; end if; Add (Param, A_Param); end if; ---------------------------------------- -- End of Element is the end of an objet ---------------------------------------- if Qname = "address_space" then Add_Address_Space (Handler.Parsed_System.Address_Spaces, Name, Cpu_Name, Text_Memory_Size, Stack_Memory_Size, Data_Memory_Size, Heap_Memory_Size, Is_Preemptive, Quantum, File_Name, A_Scheduler, Automaton_Name); Initialize_Project_Parser (Handler); end if; if Qname = "event_analyzer" then Add_Event_Analyzer (Handler.Parsed_System.Event_Analyzers, File_Name, File_Name); Initialize_Project_Parser (Handler); end if; if Qname = "network" then To_Networks_Type (Parameter_List (1), a_network_protocol, Ok); Add_Network (Handler.Parsed_System.Networks, Name, a_network_protocol); Initialize_Project_Parser (Handler); end if; if Qname = "processor" then Add_core_unit (Handler.Parsed_System.core_units, a_core, to_unbounded_string("core_unit_") & Name, Is_Preemptive, Quantum, 1.0, 0, 0, 0, File_Name, A_Scheduler, Automaton_Name); Add_Processor (Handler.Parsed_System.processors, Name, A_Network, a_core); Initialize_Project_Parser (Handler); end if; if Qname = "buffer" then Add_Buffer (Handler.Parsed_System.Buffers, A_Buff, Name, Size, Cpu_Name, Address_Space_Name, A_Qs, Roles); Initialize_Project_Parser (Handler); end if; if Qname = "message" then Add_Message (Handler.Parsed_System.Messages, A_Mess, Name, Size, Period, Deadline, Jitter, Param, Response_Time, Communication_Time); Initialize_Project_Parser (Handler); end if; if Qname = "resource" then Add_Resource (Handler.Parsed_System.Resources, Name, State, size, address, Cpu_Name, Address_Space_Name, Protocol, A_Task_Lists, Priority, priority_assignment); Initialize_Project_Parser (Handler); end if; if Qname = "task" then Add_Task (Handler.Parsed_System.Tasks, Task1, Name, Cpu_Name, Address_Space_Name, Task_Type, Start_Time, Capacity, Period, Deadline, Jitter, Blocking_Time, Priority, Criticality, Policy, Offset, Stack_Memory_Size, Text_Memory_Size, Param, Parametric_Rule, Seed, Predictable, Context_Switch_Overhead); Initialize_Project_Parser (Handler); end if; if Qname = "dependency" then if (From_Type = To_Unbounded_String ("task")) and (To_Type = To_Unbounded_String ("task")) then Task1 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (1)); Task2 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (2)); Add_One_Task_Dependency (Handler.Parsed_System.Dependencies, Task1, Task2); else if (From_Type = To_Unbounded_String ("buffer")) or (To_Type = To_Unbounded_String ("buffer")) then Reset_Iterator (Handler.Parsed_System.Buffers, Buff_Iterator); loop Current_Element (Handler.Parsed_System.Buffers, A_Buff, Buff_Iterator); if A_Buff.Name = Parameter_List (1) then Task2 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (2)); Add_One_Task_Dependency (Handler.Parsed_System.Dependencies, Task2, A_Buff, From_Object_To_Task); exit; end if; if A_Buff.Name = Parameter_List (2) then Task1 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (1)); Add_One_Task_Dependency (Handler.Parsed_System.Dependencies, Task1, A_Buff, From_Task_To_Object); exit; end if; if Is_Last_Element (Handler.Parsed_System.Buffers, Buff_Iterator) then raise Buffer_Set.Buffer_Not_Found; end if; Next_Element (Handler.Parsed_System.Buffers, Buff_Iterator); end loop; else if (From_Type = To_Unbounded_String ("message")) or (To_Type = To_Unbounded_String ("message")) then Reset_Iterator (Handler.Parsed_System.Messages, Mess_Iterator); loop Current_Element (Handler.Parsed_System.Messages, A_Mess, Mess_Iterator); if A_Mess.Name = Parameter_List (1) then Task2 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (2)); Add_One_Task_Dependency (Handler.Parsed_System.Dependencies, Task2, A_Mess, From_Object_To_Task); exit; end if; if A_Mess.Name = Parameter_List (2) then Task1 := Search_Task (Handler.Parsed_System.Tasks, Parameter_List (1)); Add_One_Task_Dependency (Handler.Parsed_System.Dependencies, Task1, A_Mess, From_Task_To_Object); exit; end if; if Is_Last_Element (Handler.Parsed_System.Messages, Mess_Iterator) then raise Message_Set.Message_Not_Found; end if; Next_Element (Handler.Parsed_System.Messages, Mess_Iterator); end loop; end if; end if; end if; Initialize_Project_Parser (Handler); end if; end End_Element; function Get_Parsed_System (Handler : in Xml_Project_Parser) return System is begin return Handler.Parsed_System; end Get_Parsed_System; ------------------------------------------------------------- ------------------------------------------------------------- -- XML event table parser ------------------------------------------------------------- ------------------------------------------------------------- Processor_Name : Unbounded_String; Task_Name : Unbounded_String; Resource_Name : Unbounded_String; Message_Name : Unbounded_String; Buffer_Name : Unbounded_String; Number : Natural; Time_Value : Natural; New_Processor_Events : Scheduling_Result_Ptr; New_Event : Time_Unit_Event_Ptr; function Get_Parsed_Event_Table (Handler : in Xml_Event_Table_Parser) return Scheduling_Table_Ptr is begin return Handler.Parsed_Event_Table; end Get_Parsed_Event_Table; procedure Set_Scheduled_System (Handler : in out Xml_Event_Table_Parser; Scheduled_System : in System) is begin Handler.Scheduled_System := Scheduled_System; end Set_Scheduled_System; procedure Initialize_Event_Table_Parser (Handler : in out Xml_Event_Table_Parser) is begin Current_Parameter := 1; end Initialize_Event_Table_Parser; procedure Start_Document (Handler : in out Xml_Event_Table_Parser) is begin Initialize_Event_Table_Parser (Handler); Handler.Parsed_Event_Table := new Scheduling_Table; end Start_Document; procedure Start_Element (Handler : in out Xml_Event_Table_Parser; Namespace_Uri : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := ""; Atts : Sax.Attributes.Attributes'Class) is begin Current_Parameter := 1; end Start_Element; procedure Read_Time_Value (Handler : in out Xml_Event_Table_Parser) is begin To_Natural (Parameter_List (1), Number, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Time_Value := Number; end Read_Time_Value; procedure End_Element (Handler : in out Xml_Event_Table_Parser; Namespace_Uri : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := "") is A_Buffer : Buffer_Ptr; A_Message : Generic_Message_Ptr; A_Task : Generic_Task_Ptr; A_Resource : Generic_Resource_Ptr; A_Processor : Generic_Processor_Ptr; begin if Qname = "name" then Processor_Name := Parameter_List (1); A_Processor := Search_Processor (Handler.Scheduled_System.Processors, Processor_Name); New_Processor_Events := new Scheduling_Result; New_Processor_Events.Has_Error := False; New_Processor_Events.Scheduling_Msg := Empty_String; New_Processor_Events.Error_Msg := Empty_String; New_Processor_Events.Result := new Scheduling_Sequence; Add (Handler.Parsed_Event_Table.all, A_Processor, New_Processor_Events.all); Initialize_Event_Table_Parser (Handler); end if; if Qname = "write_to_buffer" then Buffer_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); A_Buffer := Search_Buffer (Handler.Scheduled_System.Buffers, Buffer_Name); To_Natural (Parameter_List (4), Number, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Write_To_Buffer); New_Event.Write_Buffer := A_Buffer; New_Event.Write_Task := A_Task; New_Event.Write_Size := Number; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "read_from_buffer" then Buffer_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); A_Buffer := Search_Buffer (Handler.Scheduled_System.Buffers, Buffer_Name); To_Natural (Parameter_List (4), Number, Ok); if not Ok then Put_Line ("Warning : Error on data type. From " & To_String (Handler.Locator)); end if; Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Read_From_Buffer); New_Event.Read_Buffer := A_Buffer; New_Event.Read_Task := A_Task; New_Event.Read_Size := Number; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "send_message" then Message_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Message := Search_Message (Handler.Scheduled_System.Messages, Message_Name); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Send_Message); New_Event.Send_Task := A_Task; New_Event.Send_Message := A_Message; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "receive_message" then Message_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Message := Search_Message (Handler.Scheduled_System.Messages, Message_Name); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Receive_Message); New_Event.Receive_Task := A_Task; New_Event.Receive_Message := A_Message; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "allocate_resource" then Resource_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Resource := Search_Resource (Handler.Scheduled_System.Resources, Resource_Name); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Allocate_Resource); New_Event.Allocate_Task := A_Task; New_Event.Allocate_Resource := A_Resource; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "release_resource" then Resource_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Resource := Search_Resource (Handler.Scheduled_System.Resources, Resource_Name); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Release_Resource); New_Event.Release_Task := A_Task; New_Event.Release_Resource := A_Resource; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "wait_for_resource" then Resource_Name := Parameter_List (2); Task_Name := Parameter_List (3); A_Resource := Search_Resource (Handler.Scheduled_System.Resources, Resource_Name); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Wait_For_Resource); New_Event.Wait_for_resource_Task := A_Task; New_Event.Wait_for_Resource := A_Resource; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "task_activation" then Task_Name := Parameter_List (2); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Task_Activation); New_Event.Activation_Task := A_Task; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "running_task" then Task_Name := Parameter_List (2); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Running_Task); New_Event.Running_Task := A_Task; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "start_of_task_capacity" then Task_Name := Parameter_List (2); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (Start_Of_Task_Capacity); New_Event.Start_Task := A_Task; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; if Qname = "end_of_task_capacity" then Task_Name := Parameter_List (2); A_Task := Search_Task (Handler.Scheduled_System.Tasks, Task_Name); Read_Time_Value (Handler); New_Event := new Time_Unit_Event (End_Of_Task_Capacity); New_Event.End_Task := A_Task; Add (New_Processor_Events.Result.all, time_value, New_Event); Initialize_Event_Table_Parser (Handler); end if; end End_Element; end v2_Xml_Parsers;