Beispiel #1
0
 public Packet(SystemVertex t, TaskVertex data, int time, double w)
 {
     target = t;
     this.timeArrived = time;
     this.data = data;
     weight = w;
 }
Beispiel #2
0
        public void Assign(SystemVertex proc, TaskVertex task, int time)
        {
            this.time = time;
            if (this != proc)
            {

                foreach (var item in model.Graph.InEdges(task))
                {
                    //if (data.Contains(item.Source) && !proc.data.Contains(item.Source))
                    if (data.Contains(item.Source))
                    {
                        Packet packet = new Packet(proc, item.Source, 0, double.Parse(item.ID));
                        packets.Add(packet);
                    }
                }
                return;
            }

            data2.Clear();
            this.task = task;
            dataNeeded.Clear();
            isFree = false;

            var edges = model.Graph.InEdges(task);
            foreach (var edge in edges)
            {
                dataNeeded.Add(edge.Source);
            }

            if (dataNeeded.Count == 0)
            {
                scheduler.logs.Add("0.0." + time + "." + task.ID + "." + this.ID);
                isCalculating = true;
                calcStarted = time;
            }
            else
            {
                CheckData(time);
            }
        }
        private void LoadGraph_OnClick2(object sender, RoutedEventArgs e)
        {
            FileDialog dialog = new OpenFileDialog();
            dialog.DefaultExt = ".xml";
            dialog.Filter = "XML Documents (.xml)|*.xml";
            bool? result = dialog.ShowDialog();
            if (result != true)
            {
                return;
            }
            string path = dialog.FileName;
            SystemGraph graph = new SystemGraph(true);
            XmlDocument document = new XmlDocument();
            document.LoadXml(File.ReadAllText(path));
            XmlNodeList vertices = document.GetElementsByTagName("vertice");
            XmlNodeList edges = document.GetElementsByTagName("edge");
            foreach (XmlNode node in vertices)
            {
                SystemVertex vertex = new SystemVertex(node.Attributes[0].Value, node.Attributes[1].Value);
                graph.AddVertex(vertex);
            }

            foreach (XmlNode node in edges)
            {
                var source = graph.Vertices.First(x => x.ID == node.Attributes[1].Value);
                var target = graph.Vertices.First(x => x.ID == node.Attributes[2].Value);
                SystemEdge edge = new SystemEdge(node.Attributes[0].Value, source, target);
                SystemEdge outEdge;
                graph.TryGetEdge(source, target, out outEdge);
                if (outEdge == null)
                {
                    graph.AddEdge(edge);
                    edge = new SystemEdge(node.Attributes[0].Value, target, source);
                    graph.AddEdge(edge);
                }

            }

            vm.Graph2 = graph;
        }