private static void Main() { var processStore = ProcessParser.StringToList(File.ReadAllText("Process.txt")); RoundRobin rr = new RoundRobin(processStore.QuantumTime); foreach (IProcess t in processStore.Processes) { rr.Enqueue(t); } Console.WriteLine(rr); rr.Run(); Console.WriteLine(rr.Chart); Console.WriteLine(rr.TotalRunTime); End(); }
public static Contract FromDasFile(string path) { var contract = new Contract(); var xDoc = XDocument.Load(path, LoadOptions.SetLineInfo); var xEditorContract = xDoc.Element("EditorContract"); contract.Id = xEditorContract.Element("Id").Value; var xContractName = xEditorContract.Element("Name"); if (xContractName != null) { contract.Name = xContractName.Value; } contract.Processes = ProcessParser.ParseProcesses(xDoc.Descendants("Process")); contract.DataTypes = DataModelParser.ParseDataTypes(xDoc.Descendants("DataModel").First()); return(contract); }
static void Main(string[] args) { new Parser(settings => { settings.CaseSensitive = false; settings.CaseInsensitiveEnumValues = true; settings.HelpWriter = Console.Error; }).ParseArguments <ProcessSchedulerOptions>(args) .WithParsed(opt => { if (opt.Interactive) { Console.WriteLine("Interactive mode, press enter after any update to continue."); } var processes = ProcessParser.ParseProcesses(opt.FileName); Console.WriteLine($"Algorithm: {opt.Algorithm}"); Console.WriteLine($"Quantum: {opt.Quantum}ms"); Console.WriteLine($"Total process count: {processes.Count}"); var picker = opt.GetProcessPicker(); picker.ProcessCreated += Picker_ProcessCreated; var manager = new ProcessManager(); manager.ProcessCompleted += Manager_ProcessCompleted; manager.ProcessExecutionStarted += Manager_ProcessExecutionStarted; manager.ProcessExecutionStopped += Manager_ProcessExecutionStopped; manager.Run(processes, picker); void Picker_ProcessCreated(Process process, ProcessExecutionEventArgs args) { Line(); Log(args, $"Process {process} was created."); Line(); ReadLineIfInteractive(opt); } void Manager_ProcessExecutionStopped(ProcessExecutionEventArgs args) { Log(args, $"Process {args.Process} is now stopped. Elapsed: {Ts(args.Process.CurrentExecutionTime)}"); ReadLineIfInteractive(opt); } void Manager_ProcessExecutionStarted(ProcessExecutionEventArgs args) { Log(args, $"Process {args.Process} is now running."); } void Manager_ProcessCompleted(ProcessExecutionEventArgs args) { Line(); Log(args, $"Process {args.Process} finished executing."); Line(); ReadLineIfInteractive(opt); } }); }