private void ClearData()
 {
     FileType        = null;
     FileName        = null;
     FullFilePath    = null;
     AssemblyName    = null;
     DateOfListing   = null;
     AssyDescription = null;
     Rev             = null;
     RouteList.Clear();
     BomMap.Clear();
     BomLines.Clear();
 }
示例#2
0
 private void LocateAgent()
 {
     if (RouteList.Count > 1 || RoadGraph == null)
     {
         RoadGraph.ViewedNodes.Clear();
         RouteList         = RoadGraph.GetNodesWay(RouteList.First(), RouteList.Last());
         Position          = RouteList.First().Location;
         base.CurrentSpeed = base._maxSpeed;
         _located          = true;
     }
     else
     {
         RouteList.Clear();
     }
 }
示例#3
0
 private void ClearData()
 {
     FileType        = null;
     FileName        = null;
     FullFilePath    = null;
     HasRouting      = false;
     IsValid         = false;
     AssemblyName    = null;
     DateOfListing   = null;
     AssyDescription = null;
     Rev             = null;
     if (RouteList != null && RouteList.Count > 0)
     {
         RouteList.Clear();
     }
     if (Bom != null && Bom.Count > 0)
     {
         Bom.Clear();
     }
 }
示例#4
0
        public override void DoStep(double msInterval)
        {
            try
            {
                if (!_located)
                {
                    LocateAgent();
                }

                //Длина пути, которая может быть пройдена за один шаг моделирования
                double step_lenght = msInterval / CurrentSpeed;

                double tmp          = _currentLength;
                double route_length = 0;
                for (int i = 1; i < RouteList.Count; i++)
                {
                    //Поиск дороги
                    string     pathData = RoadGraph.GetEdgeData(RouteList[i - 1], RouteList[i]);
                    PathFigure road     = GetPathFigureFromString(pathData);
                    if (road == null)
                    {
                        throw new InvalidCastException("Не удалось десериализовать часть пути из строки (" + pathData + ")");
                    }
                    //Расчет длины маршрута и данного участка
                    double road_length = CalculatePathLength(road);
                    route_length += road_length;

                    //Если этот участок еще не пройден
                    if (_currentLength < road_length)
                    {
                        //Если участок не будет пройден за этот шаг
                        if (_currentLength + 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 (RouteList[i].IsServicePoint)
                                {
                                    //Паркуемся
                                    if (tmp != road_length - Size.X / 2)
                                    {
                                        _currentLength += road_length - tmp - Size.X / 2;
                                        Position        = CalculateCoordinateLocationOfCarrige();
                                    }
                                    //Работаем с сервисом
                                    if (!ReadyToIOOperation)
                                    {
                                        var service = _services.FirstOrDefault(s => s.Id == RouteList[i].ServiceId);
                                        if (service == null)
                                        {
                                            throw new ArgumentException("Service not found, service id = " + RouteList[i].ServiceId);
                                        }
                                        service.AddAgent(this);
                                        ReadyToIOOperation = true;
                                        //if (service is StopService)
                                        //{
                                        //    (service as StopService).OpenInputPoints(Id);
                                        //    ReadyToIOOperation = true;
                                        //}
                                    }
                                    if (_go)
                                    {
                                        ReadyToIOOperation = false;
                                        _go = false;
                                    }
                                    if (ReadyToIOOperation)
                                    {
                                        return;
                                    }
                                }

                                if (RouteList.Count > i + 1 && i > 0 && RouteList[i + 1].Equals(RouteList[i - 1]))
                                {
                                    Revers(route_length);
                                }
                            }
                            _currentLength += step_lenght;
                            Position        = CalculateCoordinateLocationOfCarrige();
                        }
                    }
                    else
                    {
                        if (i == RouteList.Count - 1)
                        {
                            _currentLength += step_lenght;
                            RouteList.Clear();
                        }
                        tmp -= road_length;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error in Thread! Agent Id [{0}]", Id));
                Console.WriteLine(ex.ToString());
                RouteList.Clear();
            }
        }