Пример #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;
 }
Пример #2
0
 private void calculateStates(SimulatorResult sr, Context ctxm)
 {
     PointD sz;
     ImageSurface state;
     Context ctx;
     foreach(ParallelAlgorithm pa in this.algorithms) {
         sz = pa.MeasureStateSize(ctxm);
         state = new ImageSurface(Format.ARGB32, (int)Math.Ceiling(sz.X), (int)Math.Ceiling(sz.Y));
         ctx = new Context(state);
         pa.PaintState(ctx);
         ((IDisposable)ctx).Dispose();
         sr.AddNodeState(pa.Name, state);
     }
 }
Пример #3
0
 private void openConfigFile(object s, EventArgs e)
 {
     FileChooserDialog fcd = new FileChooserDialog("Open Config File...", this, FileChooserAction.Open);
     fcd.TransientFor = this;
     fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
     fcd.AddButton(Stock.Ok, ResponseType.Ok);
     FileFilter ff = new FileFilter();
     ff.Name = "Config file (.xml)";
     ff.AddMimeType("text/xml");
     ff.AddMimeType("application/xml");
     fcd.AddFilter(ff);
     int result = fcd.Run();
     fcd.HideAll();
     if(result == (int)ResponseType.Ok) {
         try {
             ss.ReadConfigFile(fcd.Filename);
             this.sr = ss.Simulator.CollectResults();
             this.bs.SetMinCurrentMax(1, 1, this.sr.ChapterCount);
             this.bpsp.SimulatorResult = sr;
         }
         catch(Exception ex) {
             Console.Error.WriteLine(ex);
             MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, true, ex.Message);
             md.Run();
             md.Destroy();
         }
         this.bpsp.Reload();
     }
     fcd.Dispose();
 }