------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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 Gtk.Text_Buffer; use Gtk.Text_Buffer; with Gtk.Combo_Box; use Gtk.Combo_Box; with Ada.Text_IO; with Glib; use Glib; with Glib.Object; use Glib.Object; with graphical_editor.scheduling_simulation_draw_callbacks; use graphical_editor.scheduling_simulation_draw_callbacks; with graphical_editor.processors; use graphical_editor.processors; with Framework_Config; use Framework_Config; with Translate; use Translate; with Tasks; use Tasks; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Processors; use Processors; with Processor_Set; use Processor_Set; use Processor_Set.Generic_Processor_Set; with graphical_editor.user_message; use graphical_editor.user_message; with Gtk.Check_Button; use Gtk.Check_Button; with editor_config; use editor_config; with graphical_editor.generic_package_widget; use graphical_editor.generic_package_widget; with graphical_editor.event_analyzers; use graphical_editor.event_analyzers; with feasibility_test.feasibility_interval; use feasibility_test.feasibility_interval; package body graphical_editor.scheduling_simulation_callbacks is procedure read_Scheduling_customization_widget(Object : access Gtkada_Builder_Record'Class) is begin graphical_editor.scheduling_simulation_callbacks.close_widget(Object); Customized_Simulation := True; Last_Selected_Processor := to_Unbounded_String(Get_Active_Text(Gtk_Combo_Box(Get_Object(Object, "combobox1")))); Schedule_And_Export_Event_Table := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton12"))); Schedule_All_Processeurs := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton9"))); Run_Event_Analyzer_From_Simulation := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton10"))); Preemption_From_Simulation := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton14"))); Context_Switch_From_Simulation := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton13"))); Schedule_And_Display_Event_Table := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton11"))); Schedule_And_Export_Event_Table := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton12"))); Event_Table_File_Name := get_value_buffer_string(Gtk_Text_Buffer(Get_Object(Object, "textbuffer1"))); Xml_Event_Table_File_Name := get_value_buffer_string(Gtk_Text_Buffer(Get_Object(Object, "textbuffer1"))); Response_Time_From_Simulation (Worst_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton1"))); Response_Time_From_Simulation (Best_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton3"))); Response_Time_From_Simulation (Average_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton5"))); Response_Time_From_Simulation (Plot_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton7"))); Blocking_Time_From_Simulation (Worst_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton2"))); Blocking_Time_From_Simulation (Best_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton4"))); Blocking_Time_From_Simulation (Average_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton6"))); Blocking_Time_From_Simulation (Plot_Case) := Get_Active (Gtk_Check_Button(Get_Object(Object, "checkbutton8"))); -- Do controls : if everything is ok, open next windows -- Otherwise continue the current windows -- if schedule_and_export_event_table then if xml_event_table_file_name = empty_string then Show_Message_Box (Lb_Event_Table_File_Name(current_language) & lb_mandatory(current_language)); return; end if; end if; -- Display the widget to select scheduling simulation duration -- graphical_editor.scheduling_simulation_callbacks.Show_Scheduling_Simulation_duration_widget(Object); end read_Scheduling_customization_widget; procedure Show_Scheduling_Simulation_duration_widget (Object : access Gtkada_Builder_Record'Class) is Builder : Gtkada_Builder; Error : Glib.Error.GError; buf1 : GObject; buf2 : GObject; buf3 : GObject; A_Task : Generic_Task_Ptr; Iterator1 : Tasks_Iterator; A_Processor : Generic_Processor_Ptr; Iterator2 : Processors_Iterator; Max_Period : Natural := 0; Period : Natural := 0; Max_Draw : Natural := 1500; begin if (get_number_of_elements (Sys.Tasks) = 0) then Show_Message_Box (Lb_Define_Tasks_Before (Current_Language)); return; end if; Gtk.Main.Init; Gtk_New (Builder); Error := Add_From_File (Builder, to_string(Glade_path) & "scheduling_simulation_draw.glade"); if Error /= null then Ada.Text_IO.Put_Line ("Error : " & Get_Message (Error)); Error_Free (Error); return; end if; buf1:=Get_Object(Builder, "textbuffer1"); buf2:=Get_Object(Builder, "textbuffer2"); buf3:=Get_Object(Builder, "textbuffer3"); reset_iterator (Sys.Tasks, Iterator1); if not is_empty (sys.Tasks) then loop current_element (Sys.Tasks, A_Task, Iterator1); if (A_Task.task_type = Periodic_Type) or (A_Task.task_type = Poisson_Type) or (A_Task.task_type = Sporadic_Type) then Max_Period := Natural'Max (Max_Period, Periodic_Task_Ptr (A_Task).period); else Max_Period := Natural'Max (Max_Period, A_Task.deadline); end if; exit when is_last_element (Sys.Tasks, Iterator1); next_element (Sys.Tasks, Iterator1); end loop; end if; reset_iterator (Sys.Processors, Iterator2); loop current_element (Sys.Processors, A_Processor, Iterator2); if (Get_Number_Of_Task_From_Processor (Sys.Tasks, A_Processor.name) /= 0) then begin Period := Scheduling_Period (Sys.Tasks, A_Processor.name); if Period > Max_Period then Max_Period := Period; end if; exception when others => null; end; end if; exit when is_last_element (Sys.Processors, Iterator2); next_element (Sys.Processors, Iterator2); end loop; if (Max_Period < Max_Draw) then Max_Draw := Max_Period; end if; Set_Text(Gtk_Text_Buffer(buf1), Max_Period'Img); Set_Text(Gtk_Text_Buffer(buf2), "0"); Set_Text(Gtk_Text_Buffer(buf3), Max_Draw'Img); Register_Handler (Builder => Builder, Handler_Name => "on_button1_clicked", Handler => graphical_editor.scheduling_simulation_draw_callbacks.read_scheduling_duration_and_Draw_Scheduling'Access); Register_Handler (Builder => Builder, Handler_Name => "on_button2_clicked", Handler => graphical_editor.scheduling_simulation_draw_callbacks.Close_Widget'Access); Do_Connect (Builder); Gtk.Widget.Show_All (Get_Widget (Builder, "window1")); Gtk.Main.Main; Unref (Builder); end Show_Scheduling_Simulation_duration_widget; procedure close_widget(Object : access Gtkada_Builder_Record'Class) is my_widget : GObject; begin my_widget:=Get_Object(Object, "window1"); Destroy_cb(Gtk_Widget(my_widget)); gtk.main.main_quit; end close_widget; end graphical_editor.scheduling_simulation_callbacks;