Beispiel #1
0
        public void OpenInputPoints(int agentID)
        {
            if (IOAgent != null)
            {
                CloseInputPoints();
                IOAgent.Go();
            }
            this.IOAgent = (VehicleAgentBase)scenario.agentsList.Find(delegate(AgentBase ab) { return(ab.ID == agentID); });
            IOAgent.CurrentAgentCount = PassengersGroup.AgentDistribution[Convert.ToInt32(scenario.currentTime.TotalMinutes)] * IOAgent.MaxCapasity / 100;
            IOAgent.InputFactor       = 1.0;
            IOAgent.OutputFactor      = 1.0;
            startTime = scenario.currentTime;
            if (IOAgent != null)
            {
                output_count = Convert.ToInt32(IOAgent.OutputFactor * IOAgent.CurrentAgentCount);

                //max_input_count = agentsList.Count;
                max_input_count = IOAgent.MaxCapasity - IOAgent.CurrentAgentCount + output_count;
            }
            for (int i = 0; i < InputPoints.Count; i++)
            {
                scenario.map.SetMapFrameFlag(MapOld.CellState.Input, false, InputPoints[i].X, InputPoints[i].Y, InputPoints[i].PointWidth, InputPoints[i].PointHeight);
            }
            IsIOReady          = true;
            output_time_helper = 0;
            input_time_helper  = 0;
        }
Beispiel #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;
                }
            }
        }