Пример #1
0
 public override void AddAgent(Contracts.Agents.AgentBase agent)
 {
     if (agent is VehicleAgentBase)
     {
         _vehicle = (VehicleAgentBase)agent;
         _input_time_ms = (int)(TimeSpan.FromMinutes(1).TotalMilliseconds / _vehicle.InputFactor);
         _canInput = true;
     }
     else
     {
         _queue.Add(agent);
     }
 }
Пример #2
0
        public override void DoStep(double step_interval)
        {
            if (_canInput)
            {
                if (_queue.Count != 0)
                {
                    _current_served_time += step_interval;

                    while (_current_served_time > _input_time_ms && _queue.Count > 0)
                    {
                        _current_served_time -= _input_time_ms;
                        var first = _queue.First();
                        _map[Dislocation.LayerId].ReleasePosition(_queue.Last().Position, _queue.Last().Weigth);
                        for (int i = _queue.Count - 1; i > 0; i--)
                        {
                            _queue[i].Position = _queue[i - 1].Position;
                        }
                        first.Position = _servicePoint;
                        _queue.Remove(first);
                        _vehicle.CurrentAgentCount++;
                        if (_queue.Count == 0 || _vehicle.CurrentAgentCount >= _vehicle.MaxCapasity)
                        {
                            _current_served_time = 0;
                            _vehicle.Go();
                            _canInput = false;
                            _vehicle = null;
                        }
                        //_directions.Remove(first.Id);
                    }
                }
                else
                {
                    _current_served_time = 0;
                    _vehicle.Go();
                    _canInput = false;
                    _vehicle = null;
                }
            }
        }