------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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 Gtk.Menu_Item; use Gtk.Menu_Item; with Gtk; use Gtk; with Gtk.Main; use Gtk.Main; with Glib.Error; use Glib.Error; with Gtk.Widget; use Gtk.Widget; with Gtk.Dialog; use Gtk.Dialog; with Gtk.About_Dialog; use Gtk.About_Dialog; with Gtk.Label; use Gtk.Label; with Glib.Object; use Glib.Object; with Gtk.Text_Buffer; use Gtk.Text_Buffer; with Gtk.Combo_Box; use Gtk.Combo_Box; with Gtk.Text_Iter; use Gtk.Text_Iter; with Gtk.List_Store; use Gtk.List_Store; with Gtk.Tree_Model; use Gtk.Tree_Model; with Gtk.Tree_View; use Gtk.Tree_View; with Gtk.Tree_View_Column; use Gtk.Tree_View_Column; with Glib; use Glib; with Glib.Object; use Glib.Object; with Glib.Values; use Glib.Values; with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Exceptions; use Ada.Exceptions; with unbounded_strings; use unbounded_strings; with standards_io; use standards_io; with Ada.Numerics.Aux; use Ada.Numerics.Aux; with unbounded_strings; use unbounded_strings; use unbounded_strings.strings_table_package; with Framework_Config; use Framework_Config; with Buffer_Set; use Buffer_Set; use Buffer_Set.Generic_Buffer_Set; with Resource_Set; use Resource_Set; use Resource_Set.Generic_Resource_Set; with GNAT.Current_Exception; use GNAT.Current_Exception; with Translate; use Translate; with Networks; use Networks; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Scheduler; use Scheduler; with Scheduler.user_defined.interpreted.pipeline; use Scheduler.user_defined.interpreted.pipeline; with Scheduler.user_defined.interpreted.Automata; use Scheduler.user_defined.interpreted.Automata; with Scheduler_Interface; use Scheduler_Interface; with Processor_Set; use Processor_Set; with processors; use processors; with processor_interface; use processor_interface; with standards_io; use standards_io; use standards_io.double_io; with graphical_editor.user_message; use graphical_editor.user_message; with GNAT.Current_Exception; use GNAT.Current_Exception; with core_units; use core_units; use core_units.Core_Units_Table_Package; with graphical_editor.convert_text; use graphical_editor.convert_text; package body graphical_editor.cores is core_table_length : constant natural :=15; procedure Initialize_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is ob1: GObject:= Get_Object(Object, "textbuffer1"); ob2: GObject:= Get_Object(Object, "combobox1"); ob3: GObject:= Get_Object(Object, "textbuffer2"); ob4: GObject:= Get_Object(Object, "combobox2"); ob5: GObject:= Get_Object(Object, "textbuffer3"); ob6: GObject:= Get_Object(Object, "textbuffer4"); ob7: GObject:= Get_Object(Object, "textbuffer5"); ob8: GObject:= Get_Object(Object, "textbuffer11"); ob9: GObject:= Get_Object(Object, "textbuffer6"); ob10: GObject:= Get_Object(Object, "textbuffer7"); ob11: GObject:= Get_Object(Object, "textbuffer8"); ob12: GObject:= Get_Object(Object, "textbuffer9"); ob13: GObject:= Get_Object(Object, "liststore4"); ob14: GObject:= Get_Object(Object, "treeview1"); wid1: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob1)); wid2: t_widget := (ptype => combo, combo_value => Gtk_Combo_Box(ob2)); wid3: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob3)); wid4: t_widget := (ptype => combo, combo_value => Gtk_Combo_Box(ob4)); wid5: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob5)); wid6: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob6)); wid7: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob7)); wid8: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob8)); wid9: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob9)); wid10: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob10)); wid11: t_widget := (ptype => buffer_integer, buffer_value => Gtk_Text_Buffer(ob11)); wid12: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob12)); wid13: t_widget := (ptype => lists, list_value => Gtk_List_Store(ob13)); wid14: t_widget := (ptype => view, view_value => Gtk_Tree_View(ob14)); wid15: t_widget := (ptype => my_window, window_value => core_window); begin my_tab(1..core_table_length) := (new t_widget'(wid1), new t_widget'(wid2), new t_widget'(wid3), new t_widget'(wid4), new t_widget'(wid5), new t_widget'(wid6), new t_widget'(wid7), new t_widget'(wid8), new t_widget'(wid9), new t_widget'(wid10), new t_widget'(wid11), new t_widget'(wid12), new t_widget'(wid13), new t_widget'(wid14), new t_widget'(wid15) ); end initialize_Core; -- Data retrieved from the widgets -- core_name : unbounded_string; core_preemptive : Preemptives_Type; core_quantum : Integer; core_speed : Double; core_capacity : integer; core_period : integer; core_priority : integer; core_file_name : unbounded_string; core_scheduler : Schedulers_Type; core_automaton : unbounded_string; core_start_time : integer; core_l1_cache : unbounded_string; procedure Check_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is start_time_string, core_string, speed_string, quantum_string, period_string, capacity_string, priority_string: Unbounded_String; Integer_Ok : Boolean; double_Ok : Boolean; begin core_name := get_value_buffer_string(Gtk_Text_Buffer(my_tab(1).buffer_value)); core_scheduler := to_type(to_unbounded_string(Get_Active_Text(Gtk_Combo_Box(my_tab(2).combo_value)))).schedulers_value; quantum_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(3).buffer_value))); if (Quantum_String = "") then Core_Quantum := 0; else to_integer (Quantum_String, Core_Quantum, Integer_Ok); if not Integer_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( "Quantum" & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; core_preemptive := to_type(to_unbounded_string(Get_Active_Text(Gtk_Combo_Box(my_tab(4).combo_value)))).preemptives_value; core_automaton := get_value_buffer_string(Gtk_Text_Buffer(my_tab(5).buffer_value)); capacity_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(6).buffer_value))); if (capacity_String = "") then core_capacity := 0; else to_integer (capacity_String, Core_capacity, Integer_Ok); if not Integer_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( Lb_Capacity (Current_Language) & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; period_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(7).buffer_value))); if (period_String = "") then core_period := 0; else to_integer (period_String, core_period, Integer_Ok); if not Integer_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( Lb_Period (Current_Language) & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; priority_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(8).buffer_value))); if (priority_String = "") then core_priority := 0; else to_integer (priority_String, core_priority, Integer_Ok); if not Integer_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( Lb_priority (Current_Language) & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; core_file_name := get_value_buffer_string(Gtk_Text_Buffer(my_tab(9).buffer_value)); start_time_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(10).buffer_value))); if (start_time_String = "") then core_start_time := 0; else to_integer (start_time_String, core_start_time, Integer_Ok); if not Integer_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( Lb_start_time (Current_Language) & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; speed_string := suppress_space(get_value_buffer_string(Gtk_Text_Buffer(my_tab(11).buffer_value))); if (speed_String = "") then Core_speed := 0.0; else to_double (speed_String, Core_speed, double_Ok); if not double_Ok then Raise_Exception (processor_set.Invalid_Parameter'Identity, To_String ( "Speed" & Lb_Must_Be_Numeric (Current_Language) )); end if; end if; core_l1_cache := get_value_buffer_string(Gtk_Text_Buffer(my_tab(12).buffer_value)); Check_core_unit (core_name, core_preemptive, core_quantum, core_speed, core_capacity, core_period, core_priority, core_file_name, core_scheduler, core_automaton); end Check_Core; procedure Add_In_Sys_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is begin Processor_set.Add_core_unit (sys.Core_units, core_name, core_preemptive, core_quantum, Double(Core_speed), core_capacity, core_period, core_priority, core_file_name, core_scheduler, core_automaton, core_l1_cache, core_start_time); end Add_In_Sys_Core; procedure Deleted_In_Sys_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is A_Core : Core_Unit_Ptr; name : unbounded_string; begin name := get_value_buffer_string(Gtk_Text_Buffer(my_tab(1).buffer_value)); A_Core := Search_core_unit (sys.core_units, name); Check_Entity_Referencing_a_core_unit(sys, a_core); Delete (Sys.core_units, A_Core); end Deleted_In_Sys_Core; procedure Show_In_Sys_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is begin null; end Show_In_Sys_Core; procedure Modify_In_Sys_Core(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is id : unbounded_string; A_Core_Buffer : Core_Unit_Ptr; A_Core : Core_Unit_Ptr; a_core_from_processor : core_unit_ptr; A_Processor : Generic_Processor_Ptr; My_Iterator : Processors_Iterator; begin A_core := Search_core_unit(Sys.core_units, core_name); id:=a_core.cheddar_private_id; delete(sys.core_units, a_core); Processor_set.Add_core_unit (sys.Core_units, a_core_buffer, core_name, core_preemptive, core_quantum, Double(Core_speed), core_capacity, core_period, core_priority, core_file_name, core_scheduler, core_automaton, core_l1_cache, core_start_time); a_core_buffer.cheddar_private_id:=id; -- Update processor to take into account the updated core -- reset_iterator (sys.Processors, My_Iterator); if not is_empty (sys.Processors) then loop current_element (sys.Processors, A_Processor, My_Iterator); if A_Processor.processor_type = monocore_type then a_core_from_processor := mono_core_processor_ptr(a_processor).core; if a_core_from_processor.name = core_name then mono_core_processor_ptr(a_processor).core := a_core_buffer; end if; else for k in 0..multi_cores_processor_ptr(a_processor).cores.nb_entries-1 loop a_core_from_processor := multi_cores_processor_ptr(a_processor).cores.entries(k); if a_core_from_processor.name = core_name then multi_cores_processor_ptr(a_processor).cores.entries(k):=a_core_buffer; end if; end loop; end if; exit when is_last_element (sys.Processors, My_Iterator); next_element (sys.Processors, My_Iterator); end loop; end if; end Modify_In_Sys_Core; package core_callbacks is new generic_callbacks(Number_of_widget => core_table_length, Initialize => initialize_Core, Check => Check_Core, Add_In_Sys => Add_In_Sys_Core, Deleted_In_Sys => Deleted_In_Sys_Core, Modify_In_Sys => Modify_In_Sys_Core, Show_In_Sys => Show_In_Sys_Core); use core_callbacks; procedure Show_Core_Widget is Builder : Gtkada_Builder; Error : Glib.Error.GError; tree_iter: Gtk_Tree_Iter; A_Core : Core_Unit_Ptr; My_Iterator : core_units_Iterator; liststore: GObject; begin Gtk.Main.Init; Gtk_New (Builder); Error := Add_From_File (Builder, to_string(Glade_path) & "core.glade"); if Error /= null then Ada.Text_IO.Put_Line ("Error : " & Get_Message (Error)); Error_Free (Error); return; end if; initialize(Sys_buffer); duplicate(sys, Sys_buffer); Set_Active (Gtk_Combo_Box(Get_Object(Builder, "combobox1")), 0); Set_Active (Gtk_Combo_Box(Get_Object(Builder, "combobox2")), 0); liststore:= Get_Object(Builder, "liststore4"); reset_iterator (sys.Core_units, My_Iterator); if not is_empty (sys.Core_units) then loop current_element (sys.Core_units, A_Core, My_Iterator); Append(Gtk_List_Store(liststore), tree_iter); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 0, To_String (A_Core.name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 1, To_String(to_label(new t_all_enumeration_type'(Schedulers, A_Core.scheduling.Scheduler_Type)))); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 2, Gint(A_Core.scheduling.quantum)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 3, To_String(to_label(new t_all_enumeration_type'(Preemptives, A_Core.scheduling.preemptive_type)))); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 4, To_String(A_Core.scheduling.automaton_name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 5, Gint(A_Core.scheduling.capacity)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 6, Gint(A_Core.scheduling.period)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 7, Gint(A_Core.scheduling.priority)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 8, To_String (A_Core.scheduling.user_defined_scheduler_source_file_name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 9, Gint(A_Core.scheduling.start_time)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 10, Gint(A_Core.speed)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 11, To_String (A_Core.l1_cache_system_name)); exit when is_last_element (sys.Core_units, My_Iterator); next_element (sys.Core_units, My_Iterator); end loop; end if; Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button6_clicked", Handler => core_callbacks.Add_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button4_clicked", Handler => core_callbacks.Delected_Lign_Selected'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button2_clicked", Handler => core_callbacks.Cancel_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_treeview1_cursor_changed", Handler => core_callbacks.Show_Lign_Selected'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button5_clicked", Handler => core_callbacks.Modify_Lign'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button1_clicked", Handler => core_callbacks.Close_View'Access); Do_Connect (Builder); Gtk.Widget.Show_All (Get_Widget (Builder, "window1")); Gtk.Main.Main; Unref (Builder); end Show_Core_Widget; end graphical_editor.cores;