private void CBbuildButton_Click(object sender, EventArgs e) { Blueprint Plan = Blueprints[SelectedBlueprint, Rotation]; Point RelPoint; int BlockCount = Plan.RelPoints.Count(); short[] TileData = { 0, 0 }; Money -= Plan.Price; UpdateStatusWindow(); for (int BlockNumber = 0; BlockNumber < BlockCount; BlockNumber++) { RelPoint = Plan.RelPoints[BlockNumber]; TileData = Plan.TileData[BlockNumber]; PictureBox Tile = (PictureBox)theGrid.GetControlFromPosition(BuildLocation.X + RelPoint.X, BuildLocation.Y + RelPoint.Y); Tile.Tag = new short[] { TileData[0], TileData[1] }; // Place blueprint: if (BlockTypes[TileData[0]][TileData[1]].Outside) { Tile.BackgroundImage = BlockTypes[6][0].Tile; } else { Tile.BackgroundImage = BlockTypes[6][1].Tile; } } Point[] BuildPoints = (Point[])Plan.RelPoints.Clone(); for (int RelPointNumber = 0; RelPointNumber < BuildPoints.Count(); RelPointNumber++) { BuildPoints[RelPointNumber].X += BuildLocation.X; BuildPoints[RelPointNumber].Y += BuildLocation.Y; } switch (Plan.RoomType) { case RoomType.ClassroomSmall: Classrooms.Add(new Classroom(RoomType.ClassroomSmall, (short)numericUpDown10.Value, 30, 24, 24, 0, false, BuildPoints, Plan.TileData)); break; case RoomType.ClassroomMedium: Classrooms.Add(new Classroom(RoomType.ClassroomMedium, (short)numericUpDown10.Value, 60, 36, 36, 0, true, BuildPoints, Plan.TileData)); break; case RoomType.ClassroomLarge: Classrooms.Add(new Classroom(RoomType.ClassroomLarge, (short)numericUpDown10.Value, 90, 48, 48, 16, true, BuildPoints, Plan.TileData)); break; } TimeLine.Add(new Event(Date.AddDays(Plan.DaysToBuild), EventType.Build, new int[] { }, BuildLocation, "Construction of \"" + Language.GetString(Plan.NameResource) + "\" finishes.", "Construction of \"" + Language.GetString(Plan.NameResource) + "\" has finished.")); ExitToMainScreen(null, null); }
/// <summary> /// Adds a time interval and list of set members to the timeline. /// </summary> public void AddState(DateTime dt, params Thing[] list) { List <Thing> entities = new List <Thing>(); foreach (Thing le in list) { entities.Add(le); } TimeLine.Add(dt, new Hval(entities)); }
public void InitStdTimeLine() { var wds = Enum.GetValues(typeof(Weekdays)); foreach (var weekday in wds) { for (int i = 0; i < ClassTime.ClassIntervals.Count(); i++) { TimeLine.Add(new ClassTime { Day = (Weekdays)weekday, Number = i }); } } }
private async void ViewCommandasync(object id) { TimeLine.Clear(); int intObj = Convert.ToInt32(id); var dateNow = DateTime.Now; var date = new DateTime(dateNow.Year, dateNow.Month, intObj, 4, 5, 6); CurrentDate = String.Format("{0:dddd, MMMM d, yyyy}", date); var data = await App.Database.GetEventsbyDate(dateNow, date); foreach (var _timeline in data) { TimeLine.Add(_timeline); } }
public void Add_NewTimeLineMessage_NewMessageAdded() { var timeline = new TimeLine ( new Dictionary <DateTimeOffset, string>() ); timeline.Add ( new DateTimeOffset(2018, 11, 17, 0, 10, 30, TimeSpan.Zero), "Hello!" ); timeline .Messages .Should() .Contain ( new DateTimeOffset(2018, 11, 17, 0, 10, 30, TimeSpan.Zero), "Hello!" ); }
/// <summary> /// Sets the Tset to eternally have a given member. /// </summary> public void SetEternally(Thing val) { TimeLine.Add(Time.DawnOf, new Hval(val)); }
// Симлуляция одной итерации до отказа (или истечения времени) private IterationReport RunIteration(ComputationGraph cGraph, SimulationSettings settings, bool saveTimeline = false) { /* Идея алгоритма * Есть события (отказ или восстанолвение), которые * хранятся в куче. На вершине кучи всегда самое ближайшее событие * * Есть заявки на восстановление, которые помещаются в очередь с * какой-то политикой * * - Генерируем событие отказа, помещаем его в кучу * - Извлекаем из кучи очередное событие * - Отказ: * - Отказываем элемент * - Помещаем заявку на восстановление в очередь * - Генерируем новый отказ, помещаем в кучу * - Восстановление * - Восстанавливаем элемент * * - Каждый раз мы берем свободных воркеров и раздаем * им задачи из очереди. Каждая задача становится событием * восстановления через некоторое время */ var repairTimeList = new List <double>(); TimeDiagram diagram = null; if (saveTimeline) { diagram = new TimeDiagram(); foreach (var element in cGraph.Elements) { var tl = new TimeLine(); tl.Add(new StatePoint() { State = ElementState.OK, Time = 0 }); diagram.Add(element.Value.Data, tl); } } var heap = new Heap <SimulationEvent>(new MinPriorityComparer <SimulationEvent>()); var repairQueue = settings.RepairFactory.CreateQueue(); double t = 0; int freeWorkers = settings.RepairTeamsCount; // Генерируем первый отказ SimulationEvent ev = GenerateFailureEvent(cGraph, t); heap.Add(ev); while (cGraph.IsPathExists() && t < settings.MaxTime) { ev = heap.Pop(); t = ev.Time; if (ev.Type == EventType.FAILURE) { ev.Element.IsDestroyed = true; // Добавляем задачу в очередь на восстановление if (settings.IsRepair) { CreateRepairTask(ev, t, settings.RepairIntensity, repairQueue); } // Сохраняем событие на диаграмме if (saveTimeline) { SaveEvent(diagram, ev.Element, ElementState.FAILURE, t); } ev = GenerateFailureEvent(cGraph, t); heap.Add(ev); } else { ev.Element.IsDestroyed = false; freeWorkers++; // Сохраняем событие на диаграмме if (saveTimeline) { SaveEvent(diagram, ev.Element, ElementState.OK, t); } } // Начинаем восстанвливать while (freeWorkers > 0 && repairQueue.Count > 0 && settings.IsRepair) { var task = repairQueue.Pop(); ev = new SimulationEvent() { Element = task.Element, Time = t + task.TimeToRepair, Type = EventType.REPAIR }; heap.Add(ev); freeWorkers--; // Сохраняем статистику по восстановлению repairTimeList.Add(task.TimeToRepair); // Сохраняем событие на диаграмме if (saveTimeline) { SaveEvent(diagram, ev.Element, ElementState.REPAIR, t); } } } return(new IterationReport() { FailureTime = t, RepairTimes = repairTimeList, TimeDiagram = diagram }); }