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 unbounded_strings; use unbounded_strings; with Processors; use Processors; with Processors.extended; use Processors.extended; 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 graphical_editor.user_message; use graphical_editor.user_message; 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; package body graphical_editor.processors is PACKAGE Es_Entiers IS NEW Ada.Text_IO.Integer_IO(Integer); use Es_Entiers; procedure Initialize_Processor(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, "textbuffer2"); ob3: GObject:= Get_Object(Object, "combobox1"); ob4: GObject:= Get_Object(Object, "combobox2"); ob5: GObject:= Get_Object(Object, "liststore4"); ob6: GObject:= Get_Object(Object, "treeview2"); ob7: GObject:= Get_Object(Object, "liststore3"); ob8: GObject:= Get_Object(Object, "treeview1"); wid1: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob1)); wid2: t_widget := (ptype => buffer_string, buffer_value => Gtk_Text_Buffer(ob2)); wid3: t_widget := (ptype => combo, combo_value => Gtk_Combo_Box(ob3)); wid4: t_widget := (ptype => combo, combo_value => Gtk_Combo_Box(ob4)); wid5: t_widget := (ptype => lists, list_value => Gtk_List_Store(ob5)); wid6: t_widget := (ptype => view, view_value => Gtk_Tree_View(ob6)); wid7: t_widget := (ptype => lists, list_value => Gtk_List_Store(ob7)); wid8: t_widget := (ptype => view, view_value => Gtk_Tree_View(ob8)); wid9: t_widget := (ptype => window, window_value => processor); begin my_tab(1..processor_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)); end initialize_Processor; procedure Check_Processor(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class; Error_Message: in out Unbounded_String; Ok: in out Boolean) is processor_name: Unbounded_String; network_name: Unbounded_String; --processor_type --migration_type --liste_des_cores Integer_Ok : Boolean; begin Ok := True; -- voir avec Frank, ce qu'il faut ecrire ici, vu que dans l'ancien, on faisait un check_core_unit tjrs ... -- il faut ecrire un nouveau Check_processor, avant d'ajouter ... -- c'est ici qu'il faut verifier les contraintes ... -- verifier le nombre de coeur ... -- si 0, il faut au moins un ... si un, monocore donc pas de migration ... si plusieurs, multicore avec migrations ... end Check_Processor; procedure Add_In_Sys_Processor(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class) is begin null; end Add_In_Sys_Processor; procedure Add_In_Sys_Processor(my_tab: in out table_widget_id ; Object : access Gtkada_Builder_Record'Class; tree_iter: Gtk_Tree_Iter) is myname, mynetwork, myprocessor, mymigration, core_name: GValue; myprocessor_proc : processors_Type; mymigration_proc : migrations_Type; number_rows: integer; A_Core : Core_Unit_Ptr; Cores: Core_Units_Table; tree_iter_inter: Gtk_Tree_Iter; ok : boolean; begin Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-1).view_value)), tree_iter, 0, myname); Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-1).view_value)), tree_iter, 1, mynetwork); Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-1).view_value)), tree_iter, 2, myprocessor); myprocessor_proc := get_compatible_processor(myprocessor); Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-1).view_value)), tree_iter, 3, mymigration); mymigration_proc := get_compatible_migration(mymigration); --To_Migration_type(a_string, mymigration_proc, ok); --if not ok --then --show_message("bou"); --end if; number_rows:= get_number_elements(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value))); put(number_rows); if number_rows = 0 then Show_Message_Box (Lb_Define_core_units_Before (Current_Language)); end if; if number_rows = 1 then tree_iter_inter := Get_Iter_First (Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value))); Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value)), tree_iter_inter, 0, core_name); A_Core := Search_core_unit(sys.Core_units, to_Unbounded_String(Get_String(core_name))); Processor_set.Add_Processor(sys.Processors, to_Unbounded_String(Get_String(myname)), to_Unbounded_String(Get_String(mynetwork)), A_Core); else tree_iter_inter := Get_Iter_First (Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value))); for i in 1..number_rows loop Gtk.Tree_Model.Get_Value(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value)), tree_iter_inter, 0, core_name); A_Core := Search_core_unit(sys.Core_units, to_Unbounded_String(Get_String(core_name))); Core_Units_Table_Package.Add(Cores, A_Core); next(Gtk_Tree_Model(Gtk.Tree_View.Get_Model(my_tab(processor_table_length-3).view_value)), tree_iter_inter); end loop; Processor_set.Add_Processor(sys.Processors, to_Unbounded_String(Get_String(myname)), to_Unbounded_String(Get_String(mynetwork)), Cores, migrations_Type(mymigration_proc), processors_type(myprocessor_proc)); end if; end Add_In_Sys_Processor; function get_compatible_processor(myprocessor: GValue) return processors_type is myprocessor_proc : processors_Type; begin if to_Unbounded_String(Get_String(myprocessor)) = to_Unbounded_String("Monocore Type") then myprocessor_proc := monocore_type; end if; if to_Unbounded_String(Get_String(myprocessor)) = to_Unbounded_String("Identical Multicores Type") then myprocessor_proc := identical_multicores_type; end if; if to_Unbounded_String(Get_String(myprocessor)) = to_Unbounded_String("Uniform Multicores Type") then myprocessor_proc := uniform_multicores_type; end if; if to_Unbounded_String(Get_String(myprocessor)) = to_Unbounded_String("Unrelated Multicores Type") then myprocessor_proc := unrelated_multicores_types; end if; return myprocessor_proc; end get_compatible_processor; function get_compatible_migration(mymigration: GValue) return migrations_type is mymigration_proc: migrations_type; begin if to_Unbounded_String(Get_String(mymigration)) = to_Unbounded_String("No Migration Type") then mymigration_proc := no_migration_type; end if; if to_Unbounded_String(Get_String(mymigration)) = to_Unbounded_String("Job Level Migration Type") then mymigration_proc := job_level_migration_type; end if; if to_Unbounded_String(Get_String(mymigration)) = to_Unbounded_String("Time Unit Migration Type") then mymigration_proc := time_unit_migration_type; end if; return mymigration_proc; end get_compatible_migration; package processor_callbacks is new generic_callbacks(Number_of_widget => processor_table_length, Initialize => initialize_Processor, Check => Check_Processor, Add_In_Sys => Add_In_Sys_Processor); use processor_callbacks; procedure Add_View_Core (Object : access Gtkada_Builder_Record'Class) is tree_iter: Gtk_Tree_Iter; begin pragma Unreferenced (Object); -- avant d'ajouter, il faut faire un check, pour ne pas faire deux ajouts identique ds le listore ... Append(Gtk_List_Store(Get_Object(Object, "liststore4")), tree_iter); Gtk.List_Store.Set(Gtk_List_Store(Get_Object(Object, "liststore4")), tree_iter, 0, Get_Active_Text(Gtk_Combo_Box(Get_Object(Object, "combobox3")))); end Add_View_Core; function get_compatible_processor(myprocessor: Processors_type) return unbounded_string is myprocessor_string: Unbounded_String; begin if myprocessor = monocore_type then myprocessor_string:= to_Unbounded_String("Monocore Type"); end if; if myprocessor = identical_multicores_type then myprocessor_string:= to_Unbounded_String("Identical Multicores Type"); end if; if myprocessor = uniform_multicores_type then myprocessor_string:= to_Unbounded_String("Uniform Multicores Type"); end if; if myprocessor = unrelated_multicores_types then myprocessor_string:= to_Unbounded_String("Unrelated Multicores Type"); end if; return myprocessor_string; end get_compatible_processor; function get_compatible_migration(mymigration: migrations_type) return unbounded_string is mymigration_string: Unbounded_String; begin if mymigration = no_migration_type then mymigration_string:= to_Unbounded_String("No Migration Type"); end if; if mymigration = job_level_migration_type then mymigration_string:= to_Unbounded_String("Job Level Migration Type"); end if; if mymigration = time_unit_migration_type then mymigration_string:= to_Unbounded_String("Time Unit Migration Type"); end if; return mymigration_string; end get_compatible_migration; procedure Show_Processor_Widget is Builder : Gtkada_Builder; Error : Glib.Error.GError; tree_iter: Gtk_Tree_Iter; liststore: GObject; A_Processor : Generic_Processor_Ptr; My_Iterator : Processors_Iterator; --My_Scheduler : Generic_Scheduler_Ptr; A_Core : Core_Unit_Ptr; My_Core_Iterator : core_units_Iterator; my_combo: GObject; begin Gtk.Main.Init; Gtk_New (Builder); Error := Add_From_File (Builder, to_string(Glade_path) & "processor.glade"); if Error /= null then Ada.Text_IO.Put_Line ("Error : " & Get_Message (Error)); Error_Free (Error); return; end if; -- add values in core combo ... my_combo := Get_Object(Builder, "combobox3"); reset_iterator (sys.Core_units, My_Core_Iterator); if not is_empty (sys.Core_units) then loop current_element (sys.Core_units, A_Core, My_Core_Iterator); Append_Text (Gtk_Combo_Box(my_combo), To_String(A_Core.name)); exit when is_last_element (sys.Core_units, My_Core_Iterator); next_element (sys.Core_units, My_Core_Iterator); end loop; else Show_Message_Box (Lb_Define_core_units_Before (Current_Language)); end if; -- list in treeview list of processors liststore:= Get_Object(Builder, "liststore3"); reset_iterator (sys.Processors, My_Iterator); if not is_empty (sys.Processors) then loop current_element (sys.Processors, A_Processor, My_Iterator); Append(Gtk_List_Store(liststore), tree_iter); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 0, To_String (A_Processor.name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 1, To_String (A_Processor.network)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 2, To_String(get_compatible_processor(A_Processor.processor_type))); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 3, To_String(get_compatible_migration(A_Processor.migration_type))); exit when is_last_element (sys.Processors, My_Iterator); next_element (sys.Processors, My_Iterator); end loop; end if; Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button6_clicked", Handler => processor_callbacks.Add_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button4_clicked", Handler => processor_callbacks.Delected_Lign_Selected'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button3_clicked", Handler => processor_callbacks.Show_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button2_clicked", Handler => processor_callbacks.Cancel_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_treeview1_cursor_changed", Handler => processor_callbacks.Show_Lign_Selected'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button5_clicked", Handler => processor_callbacks.Modify_Lign'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button1_clicked", Handler => processor_callbacks.Close_View'Access); Gtkada.Builder.Register_Handler (Builder => Builder, Handler_Name => "on_button8_clicked", Handler => Add_View_Core'Access); Do_Connect (Builder); Gtk.Widget.Show_All (Get_Widget (Builder, "window1")); Gtk.Main.Main; Unref (Builder); end Show_Processor_Widget; end graphical_editor.processors;