Exemple #1
0
        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));
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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();
            });
        }
Exemple #5
0
        public void MakeSnapshot()
        {
            SaveModel();

            Guid snapshotId = LastSnapshotId;

            var  node = Tree.root.FindNode(snapshotId);
            Guid id   = node.AddNewChild();

            Tree.Save(TreeFileName);

            Experiment.Create(
                id,
                ExperimentFileName,
                MakeBackup(id),
                DirectoryPacker.Pack(ModelDir, SnapshotDataFileName, id));

            LastSnapshotId = id;

            SaveProject();
        }