Exemple #1
0
 public void SetUp()
 {
     _env = new ApplicationEnvironment();
     ProjectInfo info = ProjectInfoLoader.Load(TestConstant.Project_Drosophila);
     _unitUnderTest = new Project(info, _env);
     _unitUnderTest.UnLock();
     _unitUnderTest.LoadModel();
 }
Exemple #2
0
        /// <summary>
        /// Load the analysis directory.
        /// </summary>
        /// <param name="project">the project object.</param>
        private void LoadAnalysisDirectory(Project project)
        {
            string path = project.GetAnalysisDirectory();
            if (path == null || !Directory.Exists(path))
                return;

            string[] dirs = Directory.GetDirectories(path);
            for (int i = 0; i < dirs.Length; i++)
            {
                DirectoryInfo d = new DirectoryInfo(dirs[i]);
                string groupName = d.Name;
                string[] ele = groupName.Split(new char[] { '_' });
                if (ele.Length != 2) continue;
                string analysisName = ele[0];
                string date = ele[1];

                if (!m_env.JobManager.AnalysisDic.ContainsKey(analysisName))
                    continue;

                string modelDir = dirs[i] + "/" + Constants.ModelDirName;
                string logDir = dirs[i] + "/" + Constants.LogDirName;

                // load model
                string modelFile = modelDir + "/" + date + ".eml";
                ProjectInfo info = ProjectInfoLoader.Load(modelFile);
                string projectID = info.Name;
                Project aproject = new Project(info, m_env);
                aproject.LoadModel();

                List<EcellObject> systemObjList = aproject.SystemDic[aproject.Model.ModelID];
                List<EcellObject> stepperObjList = aproject.StepperDic[aproject.Model.ModelID];

                // create job group and analysis.
                JobGroup g = m_env.JobManager.CreateJobGroup(analysisName, date, systemObjList, stepperObjList);
                IAnalysisModule analysis = m_env.JobManager.AnalysisDic[analysisName].CreateNewInstance(g);

                // load analysis parameters.
                analysis.LoadAnalysisInfo(modelDir);
                g.LoadJobEntry(logDir);
                g.IsSaved = true;
                g.TopDir = dirs[i];
                g.UpdateStatus();
                m_env.JobManager.Update();
            }
        }
Exemple #3
0
        /// <summary>
        /// LoadProject
        /// </summary>
        /// <param name="info">the load project information.</param>
        public void LoadProject(ProjectInfo info)
        {
            List<EcellObject> passList = new List<EcellObject>();
            string message = "";
            string projectID = "";
            Project project = null;

            try
            {
                // Check Current.
                if (info == null)
                    throw new EcellException(MessageResources.ErrLoadPrj);
                if (m_currentProject != null)
                    CloseProject();

                // Create project.
                projectID = info.Name;
                message = "[" + projectID + "]";
                // Confirm Locked file.
                ConfirmLock(info);

                project = new Project(info, m_env);
                // Set current project.
                m_currentProject = project;
                m_env.PluginManager.ChangeStatus(ProjectStatus.Loading);

                // Load DMs.
                project.UnloadSimulator();
                m_env.DMDescriptorKeeper.Load(project.GetDMDirs());
                project.ReloadSimulator();

                // Create EcellProject.
                List<EcellData> ecellDataList = new List<EcellData>();
                ecellDataList.Add(new EcellData(Constants.textComment, new EcellValue(project.Info.Comment), null));
                passList.Add(EcellObject.CreateObject(projectID, "", Constants.xpathProject, "", ecellDataList));

                // Prepare datas.
                project.LoadModel();
                foreach (EcellObject model in project.ModelList)
                {
                    Trace.WriteLine(string.Format(MessageResources.InfoLoadModel, model.ModelID));
                    m_env.Console.WriteLine(string.Format(MessageResources.InfoLoadModel, model.ModelID));
                    m_env.Console.Flush();
                    passList.Add(model);
                }
                foreach (string storedModelID in project.SystemDic.Keys)
                {
                    passList.AddRange(project.StepperDic[storedModelID]);
                    passList.AddRange(project.SystemDic[storedModelID]);
                }

                // Set current project.
                m_currentProject = project;

                // Load analysis directory.
                LoadAnalysisDirectory(project);

                // Load SimulationParameters.
                LoadSimulationParameters(project);
                m_env.PluginManager.ParameterSet(projectID, project.Info.SimulationParam);
                m_editCount = 0;
                ClearSteppingModel();
            }
            catch (Exception ex)
            {
                passList = null;
                CloseProject();
                throw new EcellException(string.Format(MessageResources.ErrLoadPrj, projectID)+ "\n" + ex.Message, ex);
            }
            finally
            {
                if (m_currentProject != null)
                {
                    if (passList != null && passList.Count > 0)
                    {
                        this.m_env.PluginManager.DataAdd(passList);
                    }
                    foreach (string paramID in this.GetSimulationParameterIDs())
                    {
                        this.m_env.PluginManager.ParameterAdd(projectID, paramID);
                    }

                    m_env.ActionManager.AddAction(new LoadProjectAction(projectID, project.Info.Filename));

                    // Send Message.
                    m_env.Console.WriteLine(string.Format(MessageResources.InfoLoadPrj, projectID));
                    m_env.Console.Flush();

                    m_env.PluginManager.ChangeStatus(ProjectStatus.Loaded);
                }
            }
        }
Exemple #4
0
        public void TestConstructorProject()
        {
            _unitUnderTest.Close();

            Project testProject = null;
            Ecell.ProjectInfo info = null;
            try
            {
                testProject = new Project(info, _env);
                testProject.UnLock();
                Assert.Fail("Error param");
            }
            catch (EcellException)
            {
            }
            try
            {
                info = ProjectInfoLoader.Load(TestConstant.Model_Oscillation);
                testProject = new Project(info, null);
                testProject.UnLock();
                Assert.Fail("Error param");
            }
            catch (EcellException)
            {
            }

            info = ProjectInfoLoader.Load(TestConstant.Model_Oscillation);
            testProject = new Project(info, _env);
            testProject.UnLock();
            testProject.LoadModel();
            Assert.IsNotNull(testProject, "Constructor of type, Project failed to create instance.");

            Assert.IsNotEmpty(testProject.DmDic, "DmDic is unexpected value.");

            Assert.IsNotEmpty(testProject.InitialCondition, "InitialCondition is unexpected value.");
            Assert.IsEmpty(testProject.LogableEntityPathDic, "LogableEntityPathDic is unexpected value.");
            testProject.LogableEntityPathDic = new Dictionary<string, string>();
            Assert.IsNotNull(testProject.LogableEntityPathDic, "LogableEntityPathDic is unexpected value.");
            Assert.IsNotEmpty(testProject.LoggerPolicyDic, "LoggerPolicyDic is unexpected value.");
            Assert.IsNotNull(testProject.LoggerPolicy, "LoggerPolicy is unexpected value.");

            Assert.IsNotEmpty(testProject.ModelList, "ModelList is unexpected value.");
            Assert.IsNotNull(testProject.Model, "Model is unexpected value.");
            Assert.IsNotEmpty(testProject.StepperDic, "StepperDic is unexpected value.");
            Assert.IsNotEmpty(testProject.SystemDic, "SystemDic is unexpected value.");
            Assert.IsNotEmpty(testProject.SystemList, "SystemList is unexpected value.");
            Assert.IsNotEmpty(testProject.ProcessList, "ProcessList is unexpected value.");
            Assert.IsNotEmpty(testProject.VariableList, "VariableList is unexpected value.");
            Assert.IsNotEmpty(testProject.TextList, "TextList is unexpected value.");

            Assert.AreEqual(SimulationStatus.Wait, testProject.SimulationStatus, "SimulationStatus is unexpected value.");
            testProject.SimulationStatus = SimulationStatus.Suspended;
            Assert.AreEqual(SimulationStatus.Suspended, testProject.SimulationStatus, "SimulationStatus is unexpected value.");

            Assert.AreEqual(info, testProject.Info, "Info is unexpected value.");
            Assert.IsNotNull(testProject.Simulator, "Simulator is unexpected value.");
            testProject.Simulator = null;
            Assert.IsNull(testProject.Simulator, "Simulator is unexpected value.");

            info = ProjectInfoLoader.Load(TestConstant.Project_Drosophila);
            info.Type = ProjectType.Template;
            testProject = new Project(info, _env);
            testProject.UnLock();
            Assert.AreEqual(info, testProject.Info, "Info is unexpected value.");
        }