Esempio n. 1
0
 public SimulatorResult CollectResults()
 {
     string[] args;
     SimulatorResult sr = new SimulatorResult();
     Cairo.PointD nullp = new Cairo.PointD(-1.0d, 0.0d);
     RelativePosition rp;
     foreach(ParallelAlgorithm pa in this.algorithms) {
         rp = this.GetRelativePosition(pa);
         if(rp == null) {
             sr.AddNode(pa.Name, nullp);
         }
         else {
             sr.AddNode(pa.Name, new Cairo.PointD(rp.X, rp.Y));
         }
         if(this.initArgs.TryGetValue(pa, out args)) {
             pa.Setup(args);
         }
         else {
             pa.Setup();
         }
         this.executions.Add(pa.Steps().GetEnumerator());
     }
     foreach(Edge e in this.edges) {
         sr.AddEdge(e.Node1.Name, e.Node2.Name, e.Delay);
     }
     bool next = true;
     ImageSurface isf = new ImageSurface(Format.ARGB32, 1, 1);
     Context ctxm = new Context(isf);
     for(; next && this.time < this.MaxTime;) {
         this.calculateStates(sr, ctxm);
         foreach(Edge e in this.Edges) {
             e.DeliverPost();
         }
         next = false;
         foreach(IEnumerator<int> i in this.executions) {
             next |= i.MoveNext();
         }
         this.time++;
         foreach(Edge e in this.edges) {
             sr.AddEdgeMessages(e.Node1.Name, e.Node2.Name, this.time, e.GetDownwardsMessages(), e.GetUpwardsMessages());
         }
         if(this.newChapter) {
             this.newChapter = false;
             sr.AddChapter(this.time);
         }
     }
     ((IDisposable)ctxm).Dispose();
     sr.Cleanup(this.time);
     return sr;
 }