public void CreateNewProject(string projectName, string projectDir, string modelName) { vissim.Instance.New(); vissim.Instance.Net.Name = modelName; CreateProject(projectName, projectDir); string modelDir = Path.Combine(projectDir, project.Files.ModelDirectory); if (!Directory.Exists(modelDir)) { Directory.CreateDirectory(modelDir); } vissim.Instance.SaveNetAs(string.Format("{0}\\{1}{2}", modelDir, modelName, modelName.EndsWith(".inp") ? string.Empty : ".inp")); vissim.Instance.SaveLayout(string.Format("{0}\\vissim.ini", modelDir)); var tree = new ExperimentsTree(Path.Combine(projectDir, project.Files.SnapshotTreeFileName)); DirectoryPacker.Pack( modelDir, Path.Combine(projectDir, project.Files.SnapshotDataFileName), tree.root.Id); CreateExperiment(projectDir, tree.root.Id); project.CurrentExperimentId = tree.root.Id; project.Save(projectDir); SaveProjectToSettings(project, projectDir); OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, projectName, project.FileExtension)); }
public void MakeSnapshot() { Guid snapshotId = LastSnapshotId; var tree = ExperimentsTree.Load(SnapshotTreeFileName); var node = tree.root.FindNode(snapshotId); Guid id = node.AddNewChild(); tree.Save(SnapshotTreeFileName); experiment.Id = id; experiment.Save(Path.Combine(projectDir, project.Files.ExperimentFileName)); if (Settings.Default.ResetNewExperiment) { experiment.Reset(); } DirectoryPacker.Pack(ModelDir, SnapshotDataFileName, id); //SQLAdmin.MakeBackup(null, id, experiment.Number, @"TRANQUILLITY-PC\SQLEXPRESS", // "VISSIM", @"\\tranquillity-pc\Temp\", "sa", "Macciato777"); LastSnapshotId = id; SaveProject(); }
public void CloneProject(string projectName, string projectDir, string modelFileName) { CreateProject(projectName, projectDir); string modelName = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetInputFileName() : Path.GetFileName(modelFileName); string modelDir = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetWorkingDirectory() : Path.GetDirectoryName(modelFileName); string snapshotDataFileName = string.Format("{0}\\{1}", projectDir, project.Files.SnapshotDataFileName); var tree = new ExperimentsTree(string.Format("{0}\\{1}", projectDir, project.Files.SnapshotTreeFileName)); DirectoryPacker.Pack(modelDir, snapshotDataFileName, tree.root.Id); modelDir = string.Format("{0}\\{1}", projectDir, project.Files.ModelDirectory); if (!Directory.Exists(modelDir)) { Directory.CreateDirectory(modelDir); } DirectoryPacker.UnPack(modelDir, snapshotDataFileName, tree.root.Id); vissim.Instance.LoadNet(string.Format("{0}\\{1}{2}", modelDir, modelName, modelName.EndsWith(".inp") ? string.Empty : ".inp")); CreateExperiment(projectDir, tree.root.Id); project.CurrentExperimentId = tree.root.Id; project.Save(projectDir); SaveProjectToSettings(project, projectDir); OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, project.Name, project.FileExtension)); }
public static ExperimentsTree Load(string fileName) { var tree = new ExperimentsTree(); tree.root = ExperimentsTreeNode.Load(fileName); return(tree); }
public TreeCanvas(ProjectManager pm) { InitializeComponent(); this.pm = pm; tree = ExperimentsTree.Load(pm.SnapshotTreeFileName); Refresh(); }
private void FillTreeView(TreeNode tNode, ExperimentsTree.ExperimentsTreeNode snNode) { for (int i = 0; i < snNode.ChildsCount; i++) { var newTNode = tNode.Nodes.Add(snNode[i].Id.ToString()); if (snNode[i].ChildsCount > 0) FillTreeView(newTNode, snNode[i]); } }
public void Initialize(string projectName, string projectDir, ModelCreationMode modelMode, string model) { ThreadPool.QueueUserWorkItem(o => { OnInitialization(); Guid id = Guid.NewGuid(); this.projectDir = projectDir; Project = new Project(projectName, id); Project.Save(projectDir); SaveProjectToSettings(); tree = new ExperimentsTree(TreeFileName, id); bool pack = false; switch (modelMode) { case ModelCreationMode.cmCreateNew: pack = DirectoryPacker.Pack(ModelDir, SnapshotDataFileName, id); CreateModel(model); break; case ModelCreationMode.cmClone: pack = DirectoryPacker.Pack(model, SnapshotDataFileName, id); if (pack) { DirectoryPacker.UnPack(ModelDir, SnapshotDataFileName, id); } LoadModel(); break; } Experiment.Create(id, ExperimentFileName, MakeBackup(id), pack); OnInitialized(); }); }
public void Initialize(string projectFileName) { ThreadPool.QueueUserWorkItem(o => { OnInitialization(); projectDir = Path.GetDirectoryName(projectFileName); Project = Project.Load(projectFileName); Experiment.Load(ExperimentFileName, LastSnapshotId); tree = ExperimentsTree.Load(SnapshotTreeFileName); LoadModel(); if (Experiment.GetInstance(LastSnapshotId).HasBackup) { TakeBackup(LastSnapshotId); } OnInitialized(); }); }
private static void DrawChilds(Canvas canvas, ExperimentsTree.ExperimentsTreeNode node, Point point) { // calculate coordinates double trainLength = (node.ChildsCount - 1) * l; double startX = point.X - trainLength / 2; double startY = h * (node.Level + 1); foreach (var chld in node.ChildNodes) { //var coord = new Point(startX, startY); var el2 = new Ellipse(); el2.Tag = chld; el2.Fill = Brushes.Transparent; el2.StrokeThickness = 1; el2.Stroke = Brushes.Red; el2.Width = el2.Height = w; canvas.Children.Add(el2); Canvas.SetTop(el2, startY); Canvas.SetLeft(el2, startX); var tb2 = new TextBlock(); tb2.Text = chld.ChildsCount.ToString(); canvas.Children.Add(tb2); Canvas.SetTop(tb2, startY); Canvas.SetLeft(tb2, startX + el2.Width); } var line = new Line(); line.Stroke = Brushes.Black; line.StrokeThickness = 1; line.X1 = point.X + 20; line.Y1 = point.Y + w; line.X2 = startX + 20; line.Y2 = startY; canvas.Children.Add(line); startX += l; }
public static void DrawDownTop(Canvas canvas, ExperimentsTree.ExperimentsTreeNode node, Point point) { if (node.ChildNodes.Count > 0) DrawChilds(canvas, node, point); if (node.ParentNode != null) DrawDownTop(canvas, node, point); }
public void CloneProject(string projectName, string projectDir, string modelFileName) { CreateProject(projectName, projectDir); string modelName = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetInputFileName() : Path.GetFileName(modelFileName); string modelDir = string.IsNullOrEmpty(modelFileName) ? vissim.Instance.GetWorkingDirectory() : Path.GetDirectoryName(modelFileName); string snapshotDataFileName = string.Format("{0}\\{1}", projectDir, project.Files.SnapshotDataFileName); var tree = new ExperimentsTree(string.Format("{0}\\{1}", projectDir, project.Files.SnapshotTreeFileName)); DirectoryPacker.Pack(modelDir, snapshotDataFileName, tree.root.Id); modelDir = string.Format("{0}\\{1}", projectDir, project.Files.ModelDirectory); if (!Directory.Exists(modelDir)) Directory.CreateDirectory(modelDir); DirectoryPacker.UnPack(modelDir, snapshotDataFileName, tree.root.Id); vissim.Instance.LoadNet(string.Format("{0}\\{1}{2}", modelDir, modelName, modelName.EndsWith(".inp") ? string.Empty : ".inp")); CreateExperiment(projectDir, tree.root.Id); project.CurrentExperimentId = tree.root.Id; project.Save(projectDir); SaveProjectToSettings(project, projectDir); OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, project.Name, project.FileExtension)); }
public void CreateNewProject(string projectName, string projectDir, string modelName) { vissim.Instance.New(); vissim.Instance.Net.Name = modelName; CreateProject(projectName, projectDir); string modelDir = Path.Combine(projectDir, project.Files.ModelDirectory); if (!Directory.Exists(modelDir)) Directory.CreateDirectory(modelDir); vissim.Instance.SaveNetAs(string.Format("{0}\\{1}{2}", modelDir, modelName, modelName.EndsWith(".inp") ? string.Empty : ".inp")); vissim.Instance.SaveLayout(string.Format("{0}\\vissim.ini", modelDir)); var tree = new ExperimentsTree(Path.Combine(projectDir, project.Files.SnapshotTreeFileName)); DirectoryPacker.Pack( modelDir, Path.Combine(projectDir, project.Files.SnapshotDataFileName), tree.root.Id); CreateExperiment(projectDir, tree.root.Id); project.CurrentExperimentId = tree.root.Id; project.Save(projectDir); SaveProjectToSettings(project, projectDir); OnProjectLoaded(string.Format("{0}\\{1}{2}", projectDir, projectName, project.FileExtension)); }
public void TakeSnapshot(ExperimentsTree.ExperimentsTreeNode node) { node.Open(); node.Load(); Tree.Save(TreeFileName); if (Experiment.GetInstance(node.Id).HasSnapshot) Experiment.GetInstance(node.Id).HasSnapshot = DirectoryPacker.UnPack(ModelDir, SnapshotDataFileName, node.Id); if (Experiment.GetInstance(node.Id).HasBackup) TakeBackup(node.Id); LastSnapshotId = node.Id; SaveProject(); //string modelName = vissim.Instance.GetInputFileName(); //string modelDir = vissim.Instance.GetWorkingDirectory(); LoadModel(); }
public void Initialize(string projectName, string projectDir, ModelCreationMode modelMode, string model) { ThreadPool.QueueUserWorkItem(o => { OnInitialization(); Guid id = Guid.NewGuid(); this.projectDir = projectDir; Project = new Project(projectName, id); Project.Save(projectDir); SaveProjectToSettings(); tree = new ExperimentsTree(TreeFileName, id); bool pack = false; switch (modelMode) { case ModelCreationMode.cmCreateNew: pack = DirectoryPacker.Pack(ModelDir, SnapshotDataFileName, id); CreateModel(model); break; case ModelCreationMode.cmClone: pack = DirectoryPacker.Pack(model, SnapshotDataFileName, id); if (pack) DirectoryPacker.UnPack(ModelDir, SnapshotDataFileName, id); LoadModel(); break; } Experiment.Create(id, ExperimentFileName, MakeBackup(id), pack); OnInitialized(); }); }
public void Initialize(string projectFileName) { ThreadPool.QueueUserWorkItem(o => { OnInitialization(); projectDir = Path.GetDirectoryName(projectFileName); Project = Project.Load(projectFileName); Experiment.Load(ExperimentFileName, LastSnapshotId); tree = ExperimentsTree.Load(SnapshotTreeFileName); LoadModel(); if (Experiment.GetInstance(LastSnapshotId).HasBackup) TakeBackup(LastSnapshotId); OnInitialized(); }); }
public static void DrawTopDown(Canvas canvas, ExperimentsTree.ExperimentsTreeNode node, Point point, int currentExpNumber) { if (lastExperimentNumber != currentExpNumber) { dict = Experiment.GetDict(); lastExperimentNumber = currentExpNumber; } if (node.DescendantsCount > maxDescendantsCount) maxDescendantsCount = node.DescendantsCount; var nodeCtrl = new NodeControl(); nodeCtrl.Tag = node; nodeCtrl.Header = string.Format("Exp. Nr. {0}", dict[node.Id].Number); nodeCtrl.Counter = node.ChildsCount; nodeCtrl.lbl1.Content = "Id: " + node.Id.ToString(); nodeCtrl.lbl2.Content = "Descendants Count: " + node.DescendantsCount.ToString(); nodeCtrl.lbl3.Content = dict[node.Id].HasBackup ? "Backup - yes" : "Backup - no"; nodeCtrl.lbl4.Content = dict[node.Id].HasSnapshot ? "Snapshot - yes" : "Snapshot - no"; if (!dict[node.Id].HasBackup || !dict[node.Id].HasSnapshot) nodeCtrl.Background = Brushes.LightPink; nodeCtrl.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[node.DescendantsCount]; nodeCtrl.IsSelected = node.IsLoaded; canvas.Children.Add(nodeCtrl); Canvas.SetTop(nodeCtrl, point.Y); Canvas.SetLeft(nodeCtrl, point.X); Canvas.SetZIndex(nodeCtrl, 100); // calculate coordinates double trainLength = (node.ChildsCount - 1) * l; double startX = point.X - trainLength / 2; double startY = h * (node.Level + 1); foreach (var chld in node.ChildNodes) { if (chld.IsOpen) { DrawTopDown(canvas, chld, new Point(startX, startY), dict[chld.Id].Number); } else { var nodeCtrl2 = new NodeControl(); nodeCtrl2.Header = string.Format("Exp. Nr. {0}", dict[chld.Id].Number); nodeCtrl2.Tag = chld; nodeCtrl2.Counter = chld.ChildsCount; nodeCtrl2.lbl1.Content = "Id: " + chld.Id.ToString(); nodeCtrl2.lbl2.Content = "Descendants Count: " + chld.DescendantsCount.ToString(); nodeCtrl2.lbl3.Content = dict[chld.Id].HasBackup ? "Backup - yes" : "Backup - no"; nodeCtrl2.lbl4.Content = dict[chld.Id].HasSnapshot ? "Snapshot - yes" : "Snapshot - no"; if (!dict[chld.Id].HasBackup || !dict[chld.Id].HasSnapshot) nodeCtrl2.Background = Brushes.LightPink; nodeCtrl2.IsSelected = chld.IsLoaded; nodeCtrl2.border.Background = GradientBraker.Brake(Colors.White, Colors.LightBlue, maxDescendantsCount + 1).ToArray()[chld.DescendantsCount]; canvas.Children.Add(nodeCtrl2); Canvas.SetTop(nodeCtrl2, startY); Canvas.SetLeft(nodeCtrl2, startX); Canvas.SetZIndex(nodeCtrl2, 100); } var line = new Line(); if (!chld.IsLoaded) { line.Stroke = Brushes.Black; line.StrokeThickness = 0.3; line.StrokeDashArray = new DoubleCollection(new double[] { 35, 35 }); } else { line.Stroke = Brushes.Gold; line.StrokeThickness = 1.5; } //if (chld.IsOpen) line.StrokeThickness = 2; line.X1 = point.X + l/1.39; line.Y1 = point.Y + w/2; line.X2 = startX + l/1.39; line.Y2 = startY + w / 2; canvas.Children.Add(line); Canvas.SetZIndex(line, 99); startX += l; } }
public static ExperimentsTree Load(string fileName) { var tree = new ExperimentsTree(); tree.root = ExperimentsTreeNode.Load(fileName); return tree; }
public void BrakeSnapshot(ExperimentsTree.ExperimentsTreeNode node) { }