Ejemplo n.º 1
0
        /// <summary>
        /// Constructor of the class
        /// </summary>
        /// <param name="list">List of the processes</param>
        /// <param name="alg">Instance of the chosen algorithm</param>
        public Scheduler(List <Process> list, SchedulingAlgorithm alg)
        {
            // Set PID default value
            counter = 0;

            processList       = EncapsulateProcesses(list);
            selectedAlgorithm = alg;

            // Initialize algorithm with the list of processes
            selectedAlgorithm.Initialize(processList);

            cpu = new CPU();

            worktime   = 0;
            turn       = 1;
            elapsed    = 1;
            logCounter = 0;
            wasted     = 0;

            //Initialize EventLogger and set headers
            EventLogger.Initialize();
            EventLogger.AddEvent("Selected algorithm: " + selectedAlgorithm.GetType().Name);
            EventLogger.AddEvent("Process Count: " + processList.Count);
            EventLogger.AddEvent("Processes: ");
            processList.ForEach(x => EventLogger.AddEvent(x.Process.ToString()));
            LogCurrentState();
        }
Ejemplo n.º 2
0
 private void algList_SelectedIndexChanged(object sender, EventArgs e)
 {
     algorithm = (SchedulingAlgorithm)Activator.CreateInstance((Type)algList.SelectedItem);
     //Show Description
     descLabel.Text = algorithm.Desc();
     if (algorithm != null && algorithm.GetAlgorithmSettings() != null)
     {
         AlgorithmSettings.ISetting[] settings = algorithm.GetAlgorithmSettings().Settings;
         tlpAlgorithmSettings.Controls.Clear();
         tlpAlgorithmSettings.RowCount = algorithm.GetAlgorithmSettings().SettingsCount;
         for (int i = 0; i < algorithm.GetAlgorithmSettings().SettingsCount; ++i)
         {
             AlgorithmSettings.ISetting setting = algorithm.GetAlgorithmSettings().Settings[i];
             //Label
             tlpAlgorithmSettings.Controls.Add(CreateLabel(setting.Name, setting.Label), 0, i);
             //Data
             switch (setting.SettingType)
             {
             case AlgorithmSettings.SettingType.RANGE:
                 tlpAlgorithmSettings.Controls.Add(CreateRangeWithNumeric(
                                                       setting.Name,
                                                       ((AlgorithmSettings.RangeSetting)setting).From,
                                                       ((AlgorithmSettings.RangeSetting)setting).To,
                                                       ((AlgorithmSettings.RangeSetting)setting).Step,
                                                       ((AlgorithmSettings.RangeSetting)setting).Value,
                                                       ((AlgorithmSettings.RangeSetting)setting).Method
                                                       ), 1, i);
                 break;
             }
         }
         gbAlgorithm.Visible = true;
     }
     else
     {
         gbAlgorithm.Visible = false;
     }
 }