Example #1
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);
                }
            }
        }
 private void Read(XmlReader reader)
 {
     PaintObjectList.Clear();
     string MapTransform = "";
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             if (reader.Name == "Map")
             {
                 size = new Size(int.Parse(reader.GetAttribute("width").Split('.')[0]), int.Parse(reader.GetAttribute("height").Split('.')[0]));
                 continue;
             }
             if (reader.Name == "svg")
             {
                 size = new Size(int.Parse(reader.GetAttribute("width").Split('.')[0]), int.Parse(reader.GetAttribute("height").Split('.')[0]));
                 continue;
             }
             if (reader.Name == "g")
             {
                 MapTransform = reader.GetAttribute("transform");
                 continue;
             }
             if (reader.Name == "path")
             {
                 PaintObject obj = new PaintObject(reader.Name);
                 obj.AddAttribute("data", reader.GetAttribute("d"));
                 obj.AddAttribute("style", reader.GetAttribute("style"));
                 obj.AddAttribute("transform", reader.GetAttribute("transform"));
                 if (!string.IsNullOrEmpty(MapTransform))
                 {
                     obj.AddAttribute("maptransform", MapTransform);
                 }
                 PaintObjectList.Add(obj);
                 continue;
             }
             if (reader.Name == "rect")
             {
                 PaintObject obj = new PaintObject(reader.Name);
                 obj.AddAttribute("x", reader.GetAttribute("x"));
                 obj.AddAttribute("y", reader.GetAttribute("y"));
                 obj.AddAttribute("width", reader.GetAttribute("width"));
                 obj.AddAttribute("height", reader.GetAttribute("height"));
                 obj.AddAttribute("style", reader.GetAttribute("style"));
                 obj.AddAttribute("transform", reader.GetAttribute("transform"));
                 if (!string.IsNullOrEmpty(MapTransform))
                 {
                     obj.AddAttribute("maptransform", MapTransform);
                 }
                 PaintObjectList.Add(obj);
             }
         }
     }
     reader.Close();
 }