Ejemplo n.º 1
0
        public wndExperimentConfig(ExperimentConfig cnfg)
        {
            Cnfg = cnfg;

            InitializeComponent();

            slider           = new DoubleSlider(0, 1440, 5);
            slider.FromValue = cnfg.StartTime.TotalMinutes;
            slider.ToValue   = cnfg.StopTime.TotalMinutes;
            SliderPanel.Children.Add(slider);

            cbAgentAverangeLenght.Content          = AnalisisConstants.AGENT_AVERANGE_LENGHT_NAME;
            cbAgentAverangeLenght.IsChecked        = cnfg.AgentAverangeLenght;
            cbAgentAverangeLenghtByGroup.Content   = AnalisisConstants.AGENT_AVERANGE_LENGHT_BY_GROUP_NAME;
            cbAgentAverangeLenghtByGroup.IsChecked = cnfg.AgentAverangeLenghtByGroup;
            cbAgentAverangeSpeed.Content           = AnalisisConstants.AGENT_AVERANGE_SPEED_NAME;
            cbAgentAverangeSpeed.IsChecked         = cnfg.AgentAverangeSpeed;
            cbAgentAverangeSpeedByGroup.Content    = AnalisisConstants.AGENT_AVERANGE_SPEED_BY_GROUP_NAME;
            cbAgentAverangeSpeedByGroup.IsChecked  = cnfg.AgentAverangeSpeedByGroup;
            cbAgentAverangeTime.Content            = AnalisisConstants.AGENT_AVERANGE_TIME_NAME;
            cbAgentAverangeTime.IsChecked          = cnfg.AgentAverangeTime;
            cbAgentAverangeTimeByGroup.Content     = AnalisisConstants.AGENT_AVERANGE_TIME_BY_GROUP_NAME;
            cbAgentAverangeTimeByGroup.IsChecked   = cnfg.AgentAverangeTimeByGroup;
            cbAgentCountOnMap.Content           = AnalisisConstants.AGENT_COUNT_ON_MAP_NAME;
            cbAgentCountOnMap.IsChecked         = cnfg.AgentCountOnMap;
            cbAgentCountOnMapByGroup.Content    = AnalisisConstants.AGENT_COUNT_ON_MAP_BY_GROUP_NAME;
            cbAgentCountOnMapByGroup.IsChecked  = cnfg.AgentCountOnMapByGroup;
            cbAgentInputOutput.Content          = AnalisisConstants.AGENT_INPUT_OUTPUT_NAME;
            cbAgentInputOutput.IsChecked        = cnfg.AgentInputOutput;
            cbAgentInputOutputByGroup.Content   = AnalisisConstants.AGENT_INPUT_OUTPUT_BY_GROUP_NAME;
            cbAgentInputOutputByGroup.IsChecked = cnfg.AgentInputOutputByGroup;
            cbSpectralDensity.Content           = AnalisisConstants.SPECTRAL_DENSITY_NAME;
            cbSpectralDensity.IsChecked         = cnfg.SpectralDensity;
        }
Ejemplo n.º 2
0
        public wndExperimentConfig()
        {
            Cnfg = new ExperimentConfig();

            InitializeComponent();

            slider           = new DoubleSlider(0, 1440, 5);
            slider.FromValue = 0;
            slider.ToValue   = 1440;
            SliderPanel.Children.Add(slider);

            cbAgentAverangeLenght.Content        = AnalisisConstants.AGENT_AVERANGE_LENGHT_NAME;
            cbAgentAverangeLenghtByGroup.Content = AnalisisConstants.AGENT_AVERANGE_LENGHT_BY_GROUP_NAME;
            cbAgentAverangeSpeed.Content         = AnalisisConstants.AGENT_AVERANGE_SPEED_NAME;
            cbAgentAverangeSpeedByGroup.Content  = AnalisisConstants.AGENT_AVERANGE_SPEED_BY_GROUP_NAME;
            cbAgentAverangeTime.Content          = AnalisisConstants.AGENT_AVERANGE_TIME_NAME;
            cbAgentAverangeTimeByGroup.Content   = AnalisisConstants.AGENT_AVERANGE_TIME_BY_GROUP_NAME;
            cbAgentCountOnMap.Content            = AnalisisConstants.AGENT_COUNT_ON_MAP_NAME;
            cbAgentCountOnMapByGroup.Content     = AnalisisConstants.AGENT_COUNT_ON_MAP_BY_GROUP_NAME;
            cbAgentInputOutput.Content           = AnalisisConstants.AGENT_INPUT_OUTPUT_NAME;
            cbAgentInputOutputByGroup.Content    = AnalisisConstants.AGENT_INPUT_OUTPUT_BY_GROUP_NAME;
            cbSpectralDensity.Content            = AnalisisConstants.SPECTRAL_DENSITY_NAME;
        }
 private void OpenScenario(string path)
 {
     ScenarioReader reader = null;
     try
     {
         reader = new ScenarioReader(path);
     }
     catch (ArgumentNullException)
     {
         MessageBox.Show("Путь не задан");
         return;
     }
     catch (DirectoryNotFoundException)
     {
         MessageBox.Show("Пути " + path + " не существует");
         return;
     }
     Scenario sc = reader.ReadScenario();
     if (sc == null)
     {
         return;
     }
     scenario = sc;
     experimentCnfg = null;
     SpeedRatio = 1.0D;
     if (FirstGrid.Visibility == System.Windows.Visibility.Visible)
     {
         FirstGrid.Visibility = System.Windows.Visibility.Hidden;
     }
     PaintMap();
     menuEnableVariator.IsEnabled = true;
     Properties.Settings.Default.ScenarioPath = path;
     Properties.Settings.Default.Save();
 }
        private void NewScenario()
        {
            scenario = new Scenario();
            scenario.agentGroups = new List<AgentsGroup>();
            scenario.agentsList = new List<AgentBase>();
            scenario.ServicesList = new List<ServiceBase>();
            //scenario.RoadGraph = new Graph<WayPoint, PathFigure>();
            scenario.paintObjectList = new List<PaintObject>();
            scenario.map = new MapOld(600, 400);

            Properties.Settings.Default.ScenarioPath = null;

            SpeedRatio = 1.0D;
            experimentCnfg = null;
            PaintMap();
            menuEnableVariator.IsEnabled = true;
        }
Ejemplo n.º 5
0
        public void InitializeStepScenario(ExperimentConfig cnfg)
        {
            _scenarioConfig = cnfg;
            currentTime = cnfg.StartTime;
            int groupCount = agentGroups.Count;
            for (int i = 0; i < ServicesList.Count; i++)
            {
                if (ServicesList[i] is StopService)
                {
                    if ((ServicesList[i] as StopService).PassengersGroup != null)
                    {
                        groupCount++;
                    }
                }
                if (ServicesList[i] is TurnstileService)
                {
                    if ((ServicesList[i] as TurnstileService).TurnstileGeometry != null)
                    {
                        PaintObject obj = new PaintObject(ServicesList[i].Name);

                    }
                }
                ServicesList[i].Initialize();
            }
            _analisisViewModel = new AnalisisViewModel();

            _analisis = new AnalisisCollector(map.GetMap().GetLength(0), map.GetMap().GetLength(1), groupCount);

            if (GroupListeners != null)
            {
                foreach (var listener in GroupListeners.Values)
                {
                    listener.Stop();
                }
            }
            GroupListeners = new Dictionary<int, TcpListener>();
            ServersSocketList = new Dictionary<int, Socket>();
            agentsList = new List<AgentBase>();
            AgentByStepCounter = new Dictionary<int, double>();
            for (int i = 0; i < agentGroups.Count;i++ )
            {
                if (agentGroups[i].IsNetworkGroup)
                {
                    TcpListener tcpListener = new TcpListener(System.Net.IPAddress.Parse(agentGroups[i].Address), agentGroups[i].Port);
                    tcpListener.Start();
                    GroupListeners.Add(agentGroups[i].ID, tcpListener);
                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += new DoWorkEventHandler(AcceptAgent_DoWork);
                    worker.RunWorkerAsync(agentGroups[i]);
                }
                else
                {
                    AgentByStepCounter.Add(agentGroups[i].ID, 0);
                }
            }
        }
Ejemplo n.º 6
0
        public void InitializeScenario(ExperimentConfig cnfg)
        {
            currentTime = cnfg.StartTime;
            _analisis = new AnalisisCollector(map.GetMap().GetLength(0), map.GetMap().GetLength(1), agentGroups.Count);
            SocketWritersList = new Dictionary<int, StreamWriter>();
            IsStoped = false;

            _workersList.Clear();
            agentsList.Clear();

            foreach (var group in agentGroups.FindAll(delegate(AgentsGroup ag) { return !ag.IsServiceGroup; }))
            {
                BackgroundWorker worker = new BackgroundWorker();
                worker.WorkerSupportsCancellation = true;
                worker.DoWork += new DoWorkEventHandler(worker_DoWork);
                worker.RunWorkerAsync(group);
                _workersList.Add(worker);
                //if (group.ID == 1)
                //{
                //    try
                //    {
                //        TcpClient tcpClient;
                //        tcpClient = new TcpClient();
                //        tcpClient.NoDelay = true;
                //        tcpClient.Connect(System.Net.IPAddress.Loopback, 5554);
                //        Console.WriteLine("Соединение с 127.0.0.1:5554 установлено");
                //        NetworkStream networkStream = tcpClient.GetStream();
                //        StreamWriter streamWriter = new StreamWriter(networkStream);
                //        SocketWritersList.Add(1, streamWriter);
                //    }
                //    catch (SocketException ex)
                //    {
                //        Console.WriteLine(ex);
                //    }
                //}
            }
            _mainTimer.Interval = TimeSpan.FromMilliseconds(300);
            _mainTimer.Tick += new EventHandler(mainTimer_Tick);
            _mainTimer.Start();
            DispatcherTimer analisisTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            analisisTimer.Tick += analisisTimer_Tick;
            analisisTimer.Start();
        }
        public wndExperimentConfig(ExperimentConfig cnfg)
        {
            Cnfg = cnfg;

            InitializeComponent();

            slider = new DoubleSlider(0, 1440, 5);
            slider.FromValue = cnfg.StartTime.TotalMinutes;
            slider.ToValue = cnfg.StopTime.TotalMinutes;
            SliderPanel.Children.Add(slider);

            cbAgentAverangeLenght.Content = AnalisisConstants.AGENT_AVERANGE_LENGHT_NAME;
            cbAgentAverangeLenght.IsChecked = cnfg.AgentAverangeLenght;
            cbAgentAverangeLenghtByGroup.Content = AnalisisConstants.AGENT_AVERANGE_LENGHT_BY_GROUP_NAME;
            cbAgentAverangeLenghtByGroup.IsChecked = cnfg.AgentAverangeLenghtByGroup;
            cbAgentAverangeSpeed.Content = AnalisisConstants.AGENT_AVERANGE_SPEED_NAME;
            cbAgentAverangeSpeed.IsChecked = cnfg.AgentAverangeSpeed;
            cbAgentAverangeSpeedByGroup.Content = AnalisisConstants.AGENT_AVERANGE_SPEED_BY_GROUP_NAME;
            cbAgentAverangeSpeedByGroup.IsChecked = cnfg.AgentAverangeSpeedByGroup;
            cbAgentAverangeTime.Content = AnalisisConstants.AGENT_AVERANGE_TIME_NAME;
            cbAgentAverangeTime.IsChecked = cnfg.AgentAverangeTime;
            cbAgentAverangeTimeByGroup.Content = AnalisisConstants.AGENT_AVERANGE_TIME_BY_GROUP_NAME;
            cbAgentAverangeTimeByGroup.IsChecked = cnfg.AgentAverangeTimeByGroup;
            cbAgentCountOnMap.Content = AnalisisConstants.AGENT_COUNT_ON_MAP_NAME;
            cbAgentCountOnMap.IsChecked = cnfg.AgentCountOnMap;
            cbAgentCountOnMapByGroup.Content = AnalisisConstants.AGENT_COUNT_ON_MAP_BY_GROUP_NAME;
            cbAgentCountOnMapByGroup.IsChecked = cnfg.AgentCountOnMapByGroup;
            cbAgentInputOutput.Content = AnalisisConstants.AGENT_INPUT_OUTPUT_NAME;
            cbAgentInputOutput.IsChecked = cnfg.AgentInputOutput;
            cbAgentInputOutputByGroup.Content = AnalisisConstants.AGENT_INPUT_OUTPUT_BY_GROUP_NAME;
            cbAgentInputOutputByGroup.IsChecked = cnfg.AgentInputOutputByGroup;
            cbSpectralDensity.Content = AnalisisConstants.SPECTRAL_DENSITY_NAME;
            cbSpectralDensity.IsChecked = cnfg.SpectralDensity;
        }
        public wndExperimentConfig()
        {
            Cnfg = new ExperimentConfig();

            InitializeComponent();

            slider = new DoubleSlider(0, 1440, 5);
            slider.FromValue = 0;
            slider.ToValue = 1440;
            SliderPanel.Children.Add(slider);

            cbAgentAverangeLenght.Content = AnalisisConstants.AGENT_AVERANGE_LENGHT_NAME;
            cbAgentAverangeLenghtByGroup.Content = AnalisisConstants.AGENT_AVERANGE_LENGHT_BY_GROUP_NAME;
            cbAgentAverangeSpeed.Content = AnalisisConstants.AGENT_AVERANGE_SPEED_NAME;
            cbAgentAverangeSpeedByGroup.Content = AnalisisConstants.AGENT_AVERANGE_SPEED_BY_GROUP_NAME;
            cbAgentAverangeTime.Content = AnalisisConstants.AGENT_AVERANGE_TIME_NAME;
            cbAgentAverangeTimeByGroup.Content = AnalisisConstants.AGENT_AVERANGE_TIME_BY_GROUP_NAME;
            cbAgentCountOnMap.Content = AnalisisConstants.AGENT_COUNT_ON_MAP_NAME;
            cbAgentCountOnMapByGroup.Content = AnalisisConstants.AGENT_COUNT_ON_MAP_BY_GROUP_NAME;
            cbAgentInputOutput.Content = AnalisisConstants.AGENT_INPUT_OUTPUT_NAME;
            cbAgentInputOutputByGroup.Content = AnalisisConstants.AGENT_INPUT_OUTPUT_BY_GROUP_NAME;
            cbSpectralDensity.Content = AnalisisConstants.SPECTRAL_DENSITY_NAME;
        }