private void CalculateOtherCarrigesPosition() { for (int n = 1; n < number_of_carriges; n++) { if (need_draw[n] == false) { continue; } currentLength[n] = currentLength[0] - n * (Size.X + 2); if (currentLength[n] >= 0) { need_draw[n] = true; positions[n] = CalculateCoordinateLocationOfCarrige(n); if (positions[n] == new Point(-1, -1)) { need_draw[n] = false; } } } if (need_draw[number_of_carriges - 1] == false) { WayPointsList.Clear(); } position.X += 1; }
private void Button_Click(object sender, RoutedEventArgs e) { if ((sender as Button).Content.ToString() == "Применить") { for (int i = 0; i < WayPointVisualList.Count; i++) { WayPointsList.Add(WayPointVisualList[i].SourcePoint); } DialogResult = true; Close(); } else { DialogResult = false; Close(); } }
public override void Step() { try { if (position == new Point(-1, -1)) { LocateAgent(); } //Длина пути, которая будет пройдена за один шаг моделирвания double step_lenght = (double)Scenario.STEP_TIME_MS / CurrentSpeed; double tmp = currentLength; double route_length = 0; for (int i = 1; i < CheckPointsList.Count; i++) { //Поиск дороги PathFigure road = null; var edges = RoadGraph.GetEdgesFrom(CheckPointsList[i - 1]).GetEnumerator(); while (edges.MoveNext()) { if (edges.Current.End.Equals(CheckPointsList[i])) { road = edges.Current.Data; break; } } //Расчет длины маршрута и данного участка double road_length = CalculateLength(road); route_length += road_length; //Если этот участок еще не пройден if (tmp < road_length) { //Если участок не будет пройден за этот шаг if (tmp + step_lenght + Size.X / 2 < road_length) { currentLength += step_lenght; position = CalculateCoordinateLocationOfCarrige(); break; } else if (tmp + step_lenght + Size.X / 2 > road_length) { if (tmp + Size.X / 2 <= road_length) { if (CheckPointsList[i].IsServicePoint) { //Паркуемся if (tmp != road_length - Size.X / 2) { currentLength += road_length - tmp - Size.X / 2; position = CalculateCoordinateLocationOfCarrige(); } //Работаем с сервисом if (!ReadyToIOOperation) { ServiceBase service = scenario.ServicesList.Find(delegate(ServiceBase sb) { return(sb.ID == CheckPointsList[i].ServiceID); }); if (service.ID == -1) { throw new ArgumentException("Service not found, service id = " + CheckPointsList[i].ServiceID); } if (service is StopService) { (service as StopService).OpenInputPoints(ID); ReadyToIOOperation = true; } } if (go) { ReadyToIOOperation = false; go = false; } if (ReadyToIOOperation) { return; } } //Задержка на маршрутной точке if (CheckPointsList[i].IsWaitPoint) { if (CheckPointsList[i].MinWait > 0) { CheckPointsList[i].MinWait -= Scenario.STEP_TIME_MS; return; } } //Точка с присвоением фиксированной скорости if (CheckPointsList[i].IsFixSpeedPoint) { CurrentSpeed = Convert.ToInt32(CheckPointsList[i].FixSpeed); } else { CurrentSpeed = MaxSpeed; } if (CheckPointsList.Count > i + 1 && i > 0 && CheckPointsList[i + 1].Equals(CheckPointsList[i - 1])) { Revers(route_length); } } currentLength += step_lenght; position = CalculateCoordinateLocationOfCarrige(); break; } } else { if (i == CheckPointsList.Count - 1) { currentLength += step_lenght; } tmp -= road_length; } } } catch (Exception ex) { Console.WriteLine(string.Format("Error in Thread! Agent ID [{0}]. Error message [{1}]", ID, ex.Message)); WayPointsList.Clear(); return; } }
public virtual void Remove() { WayPointsList.Clear(); scenario.map.SetMapCellTake(false, cell.X, cell.Y); }