Пример #1
0
        /// <summary>
        /// Create the script for linux.
        /// </summary>
        /// <param name="jobID">the job id.</param>
        /// <param name="topDir">the top directory.</param>
        /// <param name="dirName">the execute directory.</param>
        /// <param name="fileName">the script file.</param>
        /// <param name="modelFile">the model file.</param>
        /// <param name="writer">the file writer.</param>
        /// <param name="modelName">the model name.</param>
        /// <param name="count">the simulation time.</param>
        /// <param name="isStep">the flag whetehr simulation is step.</param>
        /// <param name="stepperList">the list of stepper.</param>
        /// <param name="sysList">the list of system object.</param>
        /// <param name="paramDic">the dictionary of parameters.</param>
        private void CreateUnixScript(int jobID, string topDir, string dirName, string fileName, string modelFile,
            ScriptWriter writer, string modelName, double count, bool isStep, List<EcellObject> sysList,
            List<EcellObject> stepperList, Dictionary<string, double> paramDic)
        {
            Encoding enc = Encoding.GetEncoding(51932);
            SetLogTopDirectory(dirName);
            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }

            //List<string> modelList = new List<string>();
            //modelList.Add(modelName);
            //m_env.DataManager.ExportModel(modelList, modelFile);

            List<EcellObject> storedList = new List<EcellObject>();
            storedList.AddRange(stepperList);
            storedList.AddRange(sysList);
            EmlWriter.Create(modelFile, storedList, false);

            writer.ClearScriptInfo();
            File.WriteAllText(fileName, "", enc);

            writer.WriteModelEntryUnix(fileName, enc, jobID);
            foreach (EcellObject sysObj in sysList)
            {
                foreach (string path in paramDic.Keys)
                {
                    if (sysObj.Value == null) continue;
                    foreach (EcellData v in sysObj.Value)
                    {
                        if (!path.Equals(v.EntityPath))
                            continue;
                        v.Value = new EcellValue(paramDic[path]);
                        writer.WriteComponentPropertyUnix(fileName, enc, sysObj, v);
                        break;
                    }
                }
            }
            Application.DoEvents();
            foreach (EcellObject sysObj in sysList)
            {
                EcellObject tmpObj = sysObj.Clone();
                foreach (string path in paramDic.Keys)
                {
                    foreach (EcellObject obj in tmpObj.Children)
                    {
                        if (obj.Value == null) continue;
                        foreach (EcellData v in obj.Value)
                        {
                            if (!path.Equals(v.EntityPath))
                                continue;
                            v.Value = new EcellValue(paramDic[path]);
                            writer.WriteComponentPropertyUnix(fileName, enc, obj, v);
                            break;
                        }
                        Application.DoEvents();
                    }
                }
            }

            Application.DoEvents();
            List<string> sList = new List<string>();
            foreach (SaveLoggerProperty s in m_logList)
            {
                sList.Add(s.FullPath);
            }
            writer.WriteLoggerPropertyUnix(fileName, enc, sList);
            if (isStep)
                writer.WriteSimulationForStepUnix(fileName, (int)(count), enc);
            else
                writer.WriteSimulationForTimeUnix(fileName, count, enc);
            writer.WriteLoggerSaveEntryUnix(fileName, enc, jobID,
                m_logList, Proxy.GetData(GlobusJob.TOPDIR_NAME));
        }
Пример #2
0
        public void TestScriptWriterForUnix()
        {
            // Load Drosophila
            _unitUnderTest.LoadProject(TestConstant.Project_Drosophila);

            string processLog = "Process:/CELL/CYTOPLASM:R_toy10:Activity";
            string variableLob = "Variable:/CELL/CYTOPLASM:P0:Value";
            string systemLog = "System:/:CELL:Size";

            System.Text.Encoding enc = System.Text.Encoding.GetEncoding(51932);
            int jobID = 0;
            double count = 1.0;
            ScriptWriter writer = new ScriptWriter(_unitUnderTest.CurrentProject);
            List<SaveLoggerProperty> m_logList = new List<SaveLoggerProperty>();
            Dictionary<string, double> paramDic = new Dictionary<string, double>();
            m_logList.Add(new SaveLoggerProperty(processLog, 0.0, 0.0, TestConstant.TestDirectory));
            m_logList.Add(new SaveLoggerProperty(variableLob, 0.0, 0.0, TestConstant.TestDirectory));
            paramDic.Add(processLog, 10.0);
            paramDic.Add(variableLob, 10.0);
            paramDic.Add(systemLog, 0.1);

            if (File.Exists(TestConstant.Script_File))
                File.Delete(TestConstant.Script_File);

            string fileName = TestConstant.Script_File;
            File.WriteAllText(fileName, "", enc);
            writer.WriteModelEntryUnix(fileName, enc, jobID);
            foreach (EcellObject sysObj in _unitUnderTest.CurrentProject.SystemList)
            {
                EcellObject tmpObj = sysObj.Clone();
                foreach (string path in paramDic.Keys)
                {
                    foreach (EcellObject obj in tmpObj.Children)
                    {
                        if (obj.Value == null) continue;
                        foreach (EcellData v in obj.Value)
                        {
                            if (!path.Equals(v.EntityPath))
                                continue;
                            v.Value = new EcellValue(paramDic[path]);
                            writer.WriteComponentPropertyUnix(fileName, enc, obj, v);
                            break;
                        }
                    }
                }
            }
                        List<string> sList = new List<string>();
            foreach (SaveLoggerProperty s in m_logList)
            {
                sList.Add(s.FullPath);
            }

            writer.WriteLoggerPropertyUnix(fileName, enc, sList);
            writer.WriteSimulationForStepUnix(fileName, (int)(count), enc);
            writer.WriteSimulationForTimeUnix(fileName, count, enc);
            writer.WriteLoggerSaveEntryUnix(fileName, enc, jobID,
                m_logList,  TestConstant.TestDirectory);
            writer.WriteLoggerSaveEntryUnix(fileName, enc, jobID,
                m_logList, null);
            writer.WriteLoggerSaveEntryUnix(fileName, enc, jobID,
                null, TestConstant.TestDirectory);
        }