コード例 #1
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestAccessors()
        {
            string name = "TestData";
            EcellValue value = new EcellValue(0.001);
            string entityPath = "Variable:/:V0:TestData";

            EcellData data = new EcellData();
            data.Name = name;
            data.Value = value;
            data.EntityPath = entityPath;
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.AreEqual(name, data.Name, "Name is not expected value.");
            Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value.");
            Assert.AreEqual(value, data.Value, "Value is not expected value.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value.");

            data.Settable = false;
            Assert.IsFalse(data.Settable, "Settable is not expected value.");
            Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");

            data.Gettable = false;
            data.Loadable = false;
            data.Logable = false;
            data.Logged = false;
            data.Saveable = false;
            Assert.IsFalse(data.Gettable, "Gettable is not expected value.");
            Assert.IsFalse(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsFalse(data.Saveable, "Saveable is not expected value.");

            data.Gettable = true;
            data.Loadable = true;
            data.Logable = true;
            data.Logged = true;
            data.Saveable = true;
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsTrue(data.Logable, "Logable is not expected value.");
            Assert.IsTrue(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsFalse(data.Settable, "Settable is not expected value.");
            Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");

            data.Settable = true;
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value.");
        }
コード例 #2
0
ファイル: ScriptWriter.cs プロジェクト: ecell/ecell3-ide
 /// <summary>
 /// Write componentn property for Unix script.
 /// </summary>
 /// <param name="fileName">script file name.</param>
 /// <param name="enc">encoding(SJIS)</param>
 /// <param name="obj">the object.</param>
 /// <param name="data">the data of object.</param>
 public void WriteComponentPropertyUnix(string fileName, Encoding enc, EcellObject obj, EcellData data)
 {
     int i = 0;
     if (obj.Type.Equals(EcellObject.SYSTEM))
     {
         i = m_sysCount;
         m_sysCount++;
     }
     else if (obj.Type.Equals(EcellObject.PROCESS))
     {
         i = m_proCount;
         m_proCount++;
     }
     else if (obj.Type.Equals(EcellObject.VARIABLE))
     {
         i = m_varCount;
         m_varCount++;
     }
     string entName = obj.Type + i;
     File.AppendAllText(fileName,
         entName + " = createEntityStub(\"" + obj.FullID + "\")\n", enc);
     File.AppendAllText(fileName,
         entName + ".setProperty(\"" + data.Name + "\"," + data.Value.ToString() + ")\n",
         enc);
 }
コード例 #3
0
ファイル: DataStorer.cs プロジェクト: ecell/ecell3-ide
 /// <summary>
 /// Create new EcellData.
 /// </summary>
 /// <param name="name">the entity name.</param>
 /// <param name="value">the entity value.</param>
 /// <param name="entityPath">the entity path.</param>
 /// <param name="flags">property attribute object.</param>
 /// <returns></returns>
 private static EcellData CreateEcellData(string name, EcellValue value, string entityPath, PropertyAttributes flags)
 {
     EcellData data = new EcellData(name, value, entityPath);
     data.Settable = flags.Settable;
     data.Gettable = flags.Gettable;
     data.Loadable = flags.Loadable;
     data.Saveable = flags.Savable;
     return data;
 }
コード例 #4
0
ファイル: PropertyWindow.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Update the property of object in the simulation.
        /// </summary>
        private void UpdateProperties()
        {
            if (m_current == null)
                return;

            foreach (DataGridViewRow r in m_dgv.Rows)
            {
                EcellData prop = r.Cells[1].Tag as EcellData;
                if (prop == null)
                {
                    string data = r.Cells[1].Tag as string;
                    if (data.Equals(Constants.xpathID))
                        r.Cells[1].Value = m_current.LocalID;

                    continue;
                }
                EcellData d = m_current.GetEcellData(prop.Name);
                if ((m_env.PluginManager.Status == ProjectStatus.Running ||
                    m_env.PluginManager.Status == ProjectStatus.Stepping ||
                    m_env.PluginManager.Status == ProjectStatus.Suspended) &&
                    (d.Value.IsInt || d.Value.IsDouble) &&
                    d.Gettable)
                {
                    EcellValue v = m_env.DataManager.GetEntityProperty(d.EntityPath);
                    d = new EcellData(d.Name, v, d.EntityPath);
                }
                if (d == null) continue;
                if (r.Cells[1] is DataGridViewCell)
                {
                    if (!r.Cells[1].Value.ToString().Equals(d.Value.ToString()))
                    {
                        if (d.Name.Equals(Constants.xpathVRL))
                        {
                            r.Cells[1].Value = MessageResources.LabelEdit;
                        }
                        else
                        {
                            r.Cells[1].Value = d.Value.ToString();
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: PropertyWindow.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Open the contextmenustrip.
        /// Check on/of of ContextMenuStipItem.
        /// </summary>
        /// <param name="sender">ContextMenuStrip.</param>
        /// <param name="e">CancelEventArgs</param>
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            if (m_dgv.CurrentRow == null ||
                m_dgv.CurrentRow.Cells[1].Tag == null)
            {
                e.Cancel = true;
                return;
            }
            if (m_current == null || m_current.Type.Equals(Constants.xpathStepper) ||
                m_current.Type.Equals(Constants.xpathText))
            {
                e.Cancel = true;
                return;
            }
            object tag = m_dgv.CurrentRow.Cells[1].Tag;
            deleteThisPropertyToolStripMenuItem.Enabled =
                m_propDic != null && tag is EcellData &&
                !m_propDic.ContainsKey(((EcellData)tag).Name);

            loggingToolStripMenuItem.Enabled =
                tag is EcellData &&
                ((EcellData)tag).Logable;
            loggingToolStripMenuItem.Checked =
                tag is EcellData &&
                ((EcellData)tag).Logged;

            observedToolStripMenuItem.Enabled =
                tag is EcellData &&
                ((EcellData)tag).Logable;

            observedToolStripMenuItem.Checked =
                tag is EcellData &&
                m_env.DataManager.IsContainsObservedData(((EcellData)tag).EntityPath);

            parameterToolStripMenuItem.Enabled =
                tag is EcellData &&
                ((EcellData)tag).Settable && ((EcellData)tag).Value.IsDouble;
            if (tag is EcellData && ((EcellData)tag).Name.Equals(Constants.xpathSize))
            {
                string entityPath = Constants.xpathVariable + ":" + m_current.Key + ":SIZE:Value";
                parameterToolStripMenuItem.Checked =
                    m_env.DataManager.IsContainsParameterData(entityPath);
            }
            else
            {
                parameterToolStripMenuItem.Checked =
                    tag is EcellData &&
                    m_env.DataManager.IsContainsParameterData(((EcellData)tag).EntityPath);
            }

            m_data = tag != null ? tag as EcellData : null;
            if (m_current == null ||
                (!m_current.Type.Equals(EcellObject.PROCESS) &&
                !m_current.Type.Equals(EcellObject.STEPPER)))
                showTheClassDetailToolStripMenuItem.Visible = false;
            else
                showTheClassDetailToolStripMenuItem.Visible = true;
        }
コード例 #6
0
 /// <summary>
 /// Get the default parameter of DMDescriptor.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dmName"></param>
 /// <returns></returns>
 public Dictionary<string, EcellData> GetDefaultParameter(string type, string dmName)
 {
     Dictionary<string, EcellData> dic = new Dictionary<string, EcellData>();
     try
     {
         DMDescriptor desc = GetDMDescriptor(type, dmName);
         if (desc == null)
             return dic;
         // Load params.
         foreach (PropertyDescriptor prop in desc.Properties.Values)
         {
             EcellData data = new EcellData(prop.Name, prop.DefaultValue, null);
             data.Gettable = prop.Gettable;
             data.Settable = prop.Settable;
             data.Loadable = prop.Loadable;
             data.Logable = prop.Logable;
             data.Saveable = prop.Saveable;
             dic.Add(prop.Name, data);
         }
     }
     catch (Exception ex)
     {
         throw new EcellException(string.Format(MessageResources.ErrGetProp,dmName), ex);
     }
     return dic;
 }
コード例 #7
0
ファイル: Eml.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Loads the "System" elements.
        /// </summary>
        private EcellObject ParseSystem(XmlNode systemNode)
        {
            XmlNode systemClass = systemNode.Attributes.GetNamedItem(Constants.xpathClass);
            XmlNode systemID = systemNode.Attributes.GetNamedItem(Constants.xpathID.ToLower());
            if (!this.IsValidNode(systemClass) || !this.IsValidNode(systemID))
            {
                throw new EmlParseException("Invalid system node found");
            }
            if (Util.IsNGforSystemKey(systemID.InnerText))
            {
                throw new EmlParseException("Invalid system ID");
            }
            //
            // 4 "EcellCoreLib"
            //
            string parentPath = systemID.InnerText.Substring(
                    0, systemID.InnerText.LastIndexOf(Constants.delimiterPath));
            string childPath = systemID.InnerText.Substring(
                    systemID.InnerText.LastIndexOf(Constants.delimiterPath) + 1);
            if (systemID.InnerText.Equals(Constants.delimiterPath))
            {
                if (childPath.Length == 0)
                {
                    childPath = Constants.delimiterPath;
                }
            }
            else
            {
                if (parentPath.Length == 0)
                {
                    parentPath = Constants.delimiterPath;
                }
            }

            List<EcellData> ecellDataList = new List<EcellData>();
            List<EcellObject> childEcellObjectList = new List<EcellObject>();
            XmlNodeList systemPropertyList = systemNode.ChildNodes;
            foreach (XmlNode systemProperty in systemPropertyList)
            {
                if (systemProperty.Name.Equals(Constants.xpathVariable.ToLower()))
                {
                    //
                    // Parse Variable
                    //
                    EcellObject variable = ParseEntity(
                            systemProperty,
                            systemID.InnerText,
                            Constants.xpathVariable);
                    childEcellObjectList.Add(variable);
                }
                else if (systemProperty.Name.Equals(Constants.xpathProcess.ToLower()))
                {
                    //
                    // Parse Process
                    //
                    EcellObject process = ParseEntity(
                            systemProperty,
                            systemID.InnerText,
                            Constants.xpathProcess);
                    NormalizeVariableReferences(process);
                    childEcellObjectList.Add(process);
                }
                else if (systemProperty.Name.Equals(Constants.xpathText.ToLower()))
                {
                    //
                    // Parse Text
                    //
                    EcellObject text = ParseText(
                            systemProperty,
                            systemID.InnerText,
                            Constants.xpathText);
                    childEcellObjectList.Add(text);
                }
                else if (systemProperty.Name.Equals(Constants.xpathProperty))
                {
                    XmlNode systemPropertyName = systemProperty.Attributes.GetNamedItem(
                            Constants.xpathName.ToLower());
                    if (!this.IsValidNode(systemPropertyName))
                    {
                        throw new EmlParseException("Invalid property node found");
                    }

                    EcellValue ecellValue = this.ParseEcellValue(systemProperty);
                    if (ecellValue != null)
                    {
                        string entityPath =
                            Constants.xpathSystem + Constants.delimiterColon +
                            parentPath + Constants.delimiterColon +
                            childPath + Constants.delimiterColon +
                            systemPropertyName.InnerText;

                        EcellData ecellData = new EcellData(
                                systemPropertyName.InnerText,
                                ecellValue,
                                entityPath);
                        ecellDataList.Add(ecellData);
                    }
                }
            }
            //
            // 4 EcellLib
            //
            EcellObject ecellObject = EcellObject.CreateObject(
                m_modelID, systemID.InnerText, Constants.xpathSystem, systemClass.InnerText,
                ecellDataList);
            ecellObject.Children = childEcellObjectList;
            return ecellObject;
        }
コード例 #8
0
 /// <summary>
 /// Check whether the value of property is 0 or positive number.
 /// </summary>
 /// <param name="obj">The object to be checked.</param>
 /// <param name="l_data">The data to be checked.</param>
 private void IsPositiveNumberWithZero(EcellObject obj, EcellData l_data)
 {
     EcellValue val = l_data.Value;
     if (val == null)
     {
         m_errorList.Add(new ObjectPropertyReport(
             MessageType.Error,
             MessageResources.ErrNoSet,
             Constants.groupDebug,
             obj,
             l_data.Name
         ));
         return;
     }
     double d = (double)val;
     if (d < 0.0)
     {
         m_errorList.Add(new ObjectPropertyReport(
             MessageType.Error,
             MessageResources.ErrPositiveZero,
             Constants.groupDebug,
             obj,
             l_data.Name
         ));
         return;
     }
 }
コード例 #9
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestToString()
        {
            string expectedString = null;
            string resultString = null;

            EcellData data = new EcellData();
            expectedString = "";
            resultString = data.ToString();
            Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result.");

            data = new EcellData("Value", null, "Variable:/:Test:Value");
            expectedString = "Variable:/:Test:Value";
            resultString = data.ToString();
            Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(0.1), null);
            expectedString = ", 0.1";
            resultString = data.ToString();
            Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            expectedString = "Variable:/:Test:Value, 0.1";
            resultString = data.ToString();
            Assert.AreEqual(expectedString, resultString, "ToString method returned unexpected result.");
        }
コード例 #10
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestIsInitialized()
        {
            bool expectedBoolean = false;
            bool resultBoolean = false;

            EcellData data = new EcellData();
            expectedBoolean = false;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Value");
            expectedBoolean = true;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            expectedBoolean = true;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");

            data = new EcellData("Value", new EcellValue("data"), "Variable:/:Test:Value");
            expectedBoolean = false;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(new List<EcellValue>()), "Variable:/:Test:Value");
            expectedBoolean = false;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");

            data.Settable = false;
            expectedBoolean = false;
            resultBoolean = data.IsInitialized();
            Assert.AreEqual(expectedBoolean, resultBoolean, "IsInitialized method returned unexpected result.");
        }
コード例 #11
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestGetHashCode()
        {
            EcellData data = new EcellData();
            EcellData dataCopy = data.Clone();
            Assert.AreEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            dataCopy = data.Clone();
            Assert.AreEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            // NotEqual
            dataCopy = data.Clone();
            dataCopy.Gettable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Settable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Loadable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Saveable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Logable = true;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Logged = true;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Name = "Test";
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Name = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.EntityPath = "Variable:/:Test:Test";
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.EntityPath = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Value = new EcellValue(0);
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Value = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");
        }
コード例 #12
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestEquals()
        {
            // double
            bool expectedBoolean = false;
            bool resultBoolean = false;
            EcellData data1 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Value");
            EcellData data2 = new EcellData("Value1", new EcellValue(1), "Variable:/:Test:Value");
            EcellData data3 = new EcellData("Value", new EcellValue(2), "Variable:/:Test:Value");
            EcellData data4 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Test");
            EcellData data5 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // double
            data1 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", new EcellValue(0.1), "Variable:/:Test:Value");
            data3 = new EcellData("Value", new EcellValue(0.2), "Variable:/:Test:Value");
            data4 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Test");
            data5 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // string
            data1 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", new EcellValue("Test"), "Variable:/:Test:Value");
            data3 = new EcellData("Value", new EcellValue("Test2"), "Variable:/:Test:Value");
            data4 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Test");
            data5 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // List
            List<object> list1 = new List<object>();
            list1.Add("Test1");
            EcellValue value1 = new EcellValue(list1);
            List<object> list2 = new List<object>();
            list2.Add("Test2");
            EcellValue value2 = new EcellValue(list2);

            data1 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", value1.Clone(), "Variable:/:Test:Value");
            data3 = new EcellData("Value", value2.Clone(), "Variable:/:Test:Value");
            data4 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Test");
            data5 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(new object());
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            EcellData data6 = data1.Clone();
            //object obj = null;
            //data6.Value = new EcellValue(obj);
            //expectedBoolean = false;
            //resultBoolean = data1.Equals(data6);
            //Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
            //resultBoolean = data6.Equals(data1);
            //Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6.Value = null;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
            resultBoolean = data6.Equals(data1);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Gettable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Loadable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Logable = true;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Logged = true;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Saveable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Settable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
        }
コード例 #13
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestConstructorEcellDataNameValueEntityPath()
        {
            string name = null;
            EcellValue value = null;
            string entityPath = null;

            // null (uninitialized)
            EcellData data = new EcellData(name, value, entityPath);
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.IsNull(data.Name, "Name is not null.");
            Assert.IsNull(data.EntityPath, "EntityPath is not null.");
            Assert.IsNull(data.Value, "Value is not null.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");

            name = "TestData";
            entityPath = "Variable:/:V0:TestData";

            // int
            value = new EcellValue(1);
            data = new EcellData(name, value, entityPath);
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.AreEqual(name, data.Name, "Name is not expected value.");
            Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value.");
            Assert.AreEqual(value, data.Value, "Value is not expected value.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value.");

            // double
            value = new EcellValue(0.001);
            data = new EcellData(name, value, entityPath);
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.AreEqual(name, data.Name, "Name is not expected value.");
            Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value.");
            Assert.AreEqual(value, data.Value, "Value is not expected value.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsTrue(data.IsInitialized(), "IsInitialized is not expected value.");

            // string
            value = new EcellValue("test");
            data = new EcellData(name, value, entityPath);
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.AreEqual(name, data.Name, "Name is not expected value.");
            Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value.");
            Assert.IsTrue(value.Equals(data.Value), "Value is not expected value.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");

            // List
            List<EcellValue> list = new List<EcellValue>();
            value = new EcellValue(list);
            data = new EcellData(name, value, entityPath);
            Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
            Assert.AreEqual(name, data.Name, "Name is not expected value.");
            Assert.AreEqual(entityPath, data.EntityPath, "EntityPath is not expected value.");
            Assert.IsTrue(value.Equals(data.Value), "Value is not expected value.");
            Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
            Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
            Assert.IsFalse(data.Logable, "Logable is not expected value.");
            Assert.IsFalse(data.Logged, "Logged is not expected value.");
            Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
            Assert.IsTrue(data.Settable, "Settable is not expected value.");
            Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");
        }
コード例 #14
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
 public void TestConstructorEcellData()
 {
     EcellData data = new EcellData();
     Assert.IsNotNull(data, "Constructor of type, EcellData failed to create instance.");
     Assert.IsNull(data.Name, "Name is not null.");
     Assert.IsNull(data.EntityPath, "EntityPath is not null.");
     Assert.IsNull(data.Value, "Value is not null.");
     Assert.IsTrue(data.Gettable, "Gettable is not expected value.");
     Assert.IsTrue(data.Loadable, "Loadable is not expected value.");
     Assert.IsFalse(data.Logable, "Logable is not expected value.");
     Assert.IsFalse(data.Logged, "Logged is not expected value.");
     Assert.IsTrue(data.Saveable, "Saveable is not expected value.");
     Assert.IsTrue(data.Settable, "Settable is not expected value.");
     Assert.IsFalse(data.IsInitialized(), "IsInitialized is not expected value.");
 }
コード例 #15
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
        public void TestClone()
        {
            EcellData data1 =new EcellData();
            EcellData data1Copy = data1.Clone();
            Assert.AreEqual(data1, data1Copy, "Clone method returned unexpected result.");

            EcellData data2 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            EcellData data2Copy = data2.Clone();
            Assert.AreEqual(data2, data2Copy, "Clone method returned unexpected result.");

            object obj = ((ICloneable)data1).Clone();
            Assert.AreEqual(data1, obj, "Clone method returned unexpected result.");

            obj = ((ICloneable)data2).Clone();
            Assert.AreEqual(data2, obj, "Clone method returned unexpected result.");
        }
コード例 #16
0
        /// <summary>
        /// Check whether min value is smaller than max value.
        /// </summary>
        /// <param name="obj">The object to be checked.</param>
        /// <param name="l_max">The max data to be checked.</param>
        /// <param name="l_min">The min data to be checked.</param>
        private void CompareMaxAndMin(EcellObject obj, EcellData l_max, EcellData l_min)
        {
            double maxValue = (double)l_max.Value;
            double minValue = (double)l_min.Value;

            if (minValue > maxValue)
            {
                m_errorList.Add(new ObjectPropertyReport(
                    MessageType.Error,
                    MessageResources.ErrMaxMin,
                    Constants.groupDebug,
                    obj,
                    l_max.Name
                ));
            }
        }
コード例 #17
0
 /// <summary>
 /// Check whether tha type of property is bool.
 /// </summary>
 /// <param name="obj">The object to be checked.</param>
 /// <param name="l_data">The data to be checked.</param>
 private void IsBool(EcellObject obj, EcellData l_data)
 {
     EcellValue val = l_data.Value;
     if (val == null)
     {
         m_errorList.Add(new ObjectPropertyReport(
             MessageType.Error,
             MessageResources.ErrNoSet,
             Constants.groupDebug,
             obj,
             l_data.Name
         ));
     }
 }
コード例 #18
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
 public void SetUp()
 {
     _unitUnderTest = new EcellData();
 }
コード例 #19
0
ファイル: Eml.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Parses the "Stepper" node.
        /// </summary>
        /// <param name="stepper">The "Stepper" node</param>
        private EcellObject ParseStepper(XmlNode stepper)
        {
            XmlNode stepperClass = stepper.Attributes.GetNamedItem(Constants.xpathClass);
            XmlNode stepperID = stepper.Attributes.GetNamedItem(Constants.xpathID.ToLower());

            if (!IsValidNode(stepperClass) || !IsValidNode(stepperID))
                throw new SimulationParameterParseException("Invalid stepper node found");

            //
            // 4 children
            //
            List<EcellData> ecellDataList = new List<EcellData>();
            foreach (XmlNode nodeProperty in stepper.ChildNodes)
            {
                if (nodeProperty.NodeType == XmlNodeType.Whitespace)
                    continue;

                if (nodeProperty.NodeType != XmlNodeType.Element)
                {
                    throw new EmlParseException("Unexpected node");
                }

                if (!nodeProperty.Name.Equals(Constants.xpathProperty))
                {
                    throw new EmlParseException(
                        string.Format(
                            "Element {0} found where {1} is expected",
                            nodeProperty.Name, Constants.xpathProperty));
                }

                XmlNode propertyName = nodeProperty.Attributes.GetNamedItem(Constants.xpathName.ToLower());
                if (!this.IsValidNode(propertyName))
                {
                    throw new EmlParseException("Invalid property node");
                }
                EcellValue ecellValue = this.ParseEcellValue(nodeProperty);
                if (ecellValue != null)
                {
                    //
                    // 4 "EcellCoreLib"
                    //
                    EcellData ecellData = new EcellData(
                            propertyName.InnerText, ecellValue,
                            propertyName.InnerText);
                    ecellData.Gettable = true;
                    ecellData.Loadable = false;
                    ecellData.Saveable = false;
                    ecellData.Settable = true;
                    ecellDataList.Add(ecellData);
                }
            }
            //
            // 4 "EcellLib"
            //
            return EcellObject.CreateObject(
                m_modelID,
                stepperID.InnerText,
                Constants.xpathStepper,
                stepperClass.InnerText,
                ecellDataList
                );
        }
コード例 #20
0
ファイル: TestEcellData.cs プロジェクト: ecell/ecell3-ide
 public void TearDown()
 {
     _unitUnderTest = null;
 }
コード例 #21
0
ファイル: Eml.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Loads the "process" or "variable" element.
        /// </summary>
        /// <param name="node">The "process" or "variable" element</param>
        /// <param name="systemID">The system ID of the parent "System" element</param>
        /// <param name="flag">"Process" if this element is "Process" element; "Variable" otherwise</param>
        private EcellObject ParseText(
            XmlNode node,
            string systemID,
            string flag)
        {
            XmlNode nodeClass = node.Attributes.GetNamedItem(Constants.xpathClass);
            XmlNode nodeID = node.Attributes.GetNamedItem(Constants.xpathID.ToLower());
            if (!this.IsValidNode(nodeClass) || !this.IsValidNode(nodeID))
            {
                throw new EmlParseException("Invalid text node found");
            }
            // 4 children
            List<EcellData> ecellDataList = new List<EcellData>();
            XmlNodeList nodePropertyList = node.ChildNodes;
            foreach (XmlNode nodeProperty in nodePropertyList)
            {
                if (nodeProperty.NodeType == XmlNodeType.Whitespace)
                    continue;
                if (nodeProperty.NodeType != XmlNodeType.Element)
                    throw new EmlParseException("Unexpected node");
                if (!nodeProperty.Name.Equals(Constants.xpathProperty))
                    throw new EmlParseException(
                        string.Format(
                            "Element {0} found where {1} is expected",
                            nodeProperty.Name, Constants.xpathProperty));
                XmlNode nodePropertyName = nodeProperty.Attributes.GetNamedItem(Constants.xpathName.ToLower());
                if (!this.IsValidNode(nodePropertyName))
                    continue;

                EcellValue ecellValue = new EcellValue(nodeProperty.InnerText);
                if (ecellValue == null)
                    continue;

                // 4 "EcellCoreLib"
                string entityPath =
                    flag + Constants.delimiterColon +
                    systemID + Constants.delimiterColon +
                    nodeID.InnerText + Constants.delimiterColon +
                    nodePropertyName.InnerText;

                EcellData ecellData = new EcellData(nodePropertyName.InnerText, ecellValue, entityPath);
                ecellDataList.Add(ecellData);
            }
            // 4 "EcellLib"
            return EcellObject.CreateObject(
                    m_modelID,
                    systemID + Constants.delimiterColon + nodeID.InnerText,
                    flag,
                    nodeClass.InnerText,
                    ecellDataList);
        }
コード例 #22
0
        /// <summary>
        /// Parses the "Stepper" node.
        /// </summary>
        /// <param name="modelID">The model ID</param>
        /// <param name="stepper">The "Stepper" node</param>
        private EcellObject ParseStepper(string modelID, XmlNode stepper)
        {
            XmlNode stepperClass = stepper.Attributes.GetNamedItem(Constants.xpathClass);
            XmlNode stepperID = stepper.Attributes.GetNamedItem(Constants.xpathID.ToLower());
            if (!this.IsValidNode(stepperClass) || !this.IsValidNode(stepperID))
            {
                throw new SimulationParameterParseException("Invalid stepper node found");
            }

            try
            {
                m_simulator.CreateStepper(stepperClass.InnerText, stepperID.InnerText);
            }
            catch (Exception e)
            {
                throw new EcellException(
                    String.Format(
                        "Could not create {0}",
                        new object[] { stepperClass.InnerText }),
                    e
                );
            }

            List<EcellData> ecellDataList = new List<EcellData>();
            XmlNodeList stepperPropertyList = stepper.ChildNodes;
            foreach (XmlNode stepperProperty in stepperPropertyList)
            {
                if (!stepperProperty.Name.Equals(Constants.xpathProperty))
                {
                    continue;
                }
                XmlNode stepperPropertyName = stepperProperty.Attributes.GetNamedItem(Constants.xpathName.ToLower());
                if (!this.IsValidNode(stepperPropertyName))
                {
                    continue;
                }
                EcellValue ecellValue = this.ParseEcellValue(stepperProperty);
                if (ecellValue != null)
                {
                    //
                    // 4 "EcellCoreLib"
                    //
                    m_simulator.LoadStepperProperty(
                        stepperID.InnerText,
                        stepperPropertyName.InnerText,
                        ecellValue.Value);
                    EcellData ecellData = new EcellData(
                            stepperPropertyName.InnerText, ecellValue, stepperPropertyName.InnerText);
                    ecellData.Gettable = true;
                    ecellData.Loadable = false;
                    ecellData.Saveable = false;
                    ecellData.Settable = true;
                    ecellDataList.Add(ecellData);
                }
            }

            //
            // 4 "EcellLib"
            //
            return EcellObject.CreateObject(
                modelID,
                stepperID.InnerText,
                Constants.xpathStepper,
                stepperClass.InnerText,
                ecellDataList);
        }
コード例 #23
0
ファイル: PropertyWindow.cs プロジェクト: ecell/ecell3-ide
 /// <summary>
 /// Change the selection of ComboBox.
 /// </summary>
 /// <param name="sender">DataGridViewComboBoxEditingControl</param>
 /// <param name="e">EventArgs</param>
 private void combo_selectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         string newClassName = (string)((DataGridViewComboBoxEditingControl)sender).SelectedItem;
         if (newClassName.Equals(m_current.Classname))
         {
             return;
         }
         List<EcellData> props = new List<EcellData>();
         // Get Process properties.
         if (m_current.Type == Constants.xpathProcess)
         {
             Dictionary<string, EcellData> properties = m_env.DataManager.GetProcessProperty(newClassName);
             foreach (KeyValuePair<string, EcellData> pair in properties)
             {
                 EcellData val = pair.Value;
                 if (pair.Value.Name == Constants.xpathStepperID)
                 {
                     List<EcellObject> steppers = m_env.DataManager.GetStepper(m_current.ModelID);
                     if (steppers.Count > 0)
                     {
                         val = new EcellData(pair.Value.Name,
                             new EcellValue(steppers[0].Key),
                             val.EntityPath);
                     }
                 }
                 else if (pair.Value.Name == Constants.xpathVRL)
                 {
                     EcellData d = m_current.GetEcellData(Constants.xpathVRL);
                     if (d != null)
                         val = d;
                 }
                 else if (pair.Value.Name == Constants.xpathK && newClassName.Equals(Constants.DefaultProcessName))
                 {
                     val.Value = new EcellValue(1.0);
                 }
                 props.Add(val);
             }
         }
         else
         {
             props = m_env.DataManager.GetStepperProperty(newClassName);
         }
         EcellObject obj = EcellObject.CreateObject(
             m_current.ModelID, m_current.Key, m_current.Type,
             newClassName, props);
         obj.SetPosition(m_current);
         NotifyDataChanged(obj.ModelID, obj.Key, obj);
         ReloadProperties();
     }
     catch (Exception ex)
     {
         Util.ShowErrorDialog(ex.Message);
         ReloadProperties();
     }
 }
コード例 #24
0
ファイル: DataManager.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Update the property when DataChanged is executed,
        /// </summary>
        /// <param name="variable">the variable object.</param>
        /// <param name="updateData">the update data.</param>
        public void UpdatePropertyForDataChanged(EcellObject variable, EcellData updateData)
        {
            if (variable.LocalID.Equals(EcellSystem.SIZE))
                return;

            //  check old data;
            EcellObject old = GetEcellObject(variable.ModelID, variable.Key, variable.Type);
            if (old == null)
                return;
            if (updateData == null)
            {
                foreach (EcellData orgdata in old.Value)
                {
                    if (!orgdata.Settable)
                        continue;
                    updateData = variable.GetEcellData(orgdata.Name);
                    if (updateData == null)
                        continue;
                    if (!updateData.Value.ToString().Equals(orgdata.Value.ToString()))
                    {
                        break;
                    }
                    updateData = null;
                }
            }
            if (updateData == null)
                return;

            EcellObject sys = GetEcellObject(variable.ModelID, variable.ParentSystemID, Constants.xpathSystem);
            string variablePath = Constants.delimiterPath + Constants.delimiterColon + "V0";
            string sizePath = Constants.delimiterPath + Constants.delimiterColon + Constants.xpathSize.ToUpper();
            string sizeValuePath = Constants.xpathVariable + Constants.delimiterColon + sizePath +
                Constants.delimiterColon + Constants.xpathValue;
            WrappedSimulator sim = null;
            EcellObject dummySizeObject = null;
            EcellObject variableObject = null;
            Dictionary<string, EcellData> dic = new Dictionary<string, EcellData>();
            try
            {
                sim = m_currentProject.CreateSimulatorInstance();
                BuildDefaultSimulator(sim, null, null);
                dummySizeObject = EcellObject.CreateObject(
                    "",
                    sizePath,
                    EcellObject.VARIABLE,
                    EcellObject.VARIABLE,
                    null
                    );
                sim.SetEntityProperty(sizeValuePath, ((EcellSystem)sys).SizeInVolume);
                sim.CreateEntity(Constants.xpathVariable, Constants.xpathVariable + Constants.delimiterColon + variablePath);
                foreach (EcellData data in variable.Value)
                {
                    if (!data.Settable) continue;
                    if (data.Name.Equals(updateData.Name)) continue;
                    sim.SetEntityProperty(
                        Constants.xpathVariable + Constants.delimiterColon + variablePath +
                        Constants.delimiterColon + data.Name, data.Value.Value);
                }
                sim.SetEntityProperty(
                    Constants.xpathVariable + Constants.delimiterColon + variablePath +
                    Constants.delimiterColon + updateData.Name, updateData.Value.Value);

                variableObject = EcellObject.CreateObject(
                    "",
                    variablePath,
                    EcellObject.VARIABLE,
                    EcellObject.VARIABLE,
                    null
                    );
                DataStorer.DataStored4Variable(
                    sim,
                    variableObject,
                    new Dictionary<string, double>());

                SetPropertyList(variableObject, dic);
                foreach (string name in dic.Keys)
                {
                    EcellData tmp = variable.GetEcellData(name);
                    tmp.Value = dic[name].Value;
                }
            }
            finally
            {
                sim.Dispose();
                sim = null;
                variableObject = null;
            }
        }
コード例 #25
0
ファイル: PropertyWindow.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Reload the propety of object.
        /// </summary>
        private void ReloadProperties()
        {
            m_propDic = null;
            m_dgv.Rows.Clear();
            if (m_current == null)
                return;

            string localID = m_current.LocalID;
            string parentSystemPath = m_current.ParentSystemID;

            if (m_current.Type == Constants.xpathProcess &&
                    m_env.DataManager.IsEnableAddProperty(m_current.Classname))
            {
                defineANewPropertyToolStripMenuItem.Enabled = true;
                m_propDic = m_env.DataManager.GetProcessProperty(m_current.Classname);
            }
            else
            {
                defineANewPropertyToolStripMenuItem.Enabled = false;
                deleteThisPropertyToolStripMenuItem.Enabled = false;
                m_propDic = null;
            }

            {
                AddNonDataProperty("ModelID", m_current.ModelID, true);
                AddNonDataProperty("ID", localID, false);
                AddNonDataProperty("ClassName", m_current.Classname, false);
            }

            EcellData sizeData = null;
            foreach (EcellData d in m_current.Value)
            {
                if (d.Name == Constants.xpathSize)
                {
                    sizeData = d;
                    continue;
                }

                AddProperty(d, m_current.Type);
                if (d.Name == EcellProcess.VARIABLEREFERENCELIST)
                    m_refList = EcellReference.ConvertFromEcellValue(d.Value);
            }

            if (m_current.Type == Constants.xpathSystem)
            {
                EcellSystem system = (EcellSystem)m_current;
                EcellData dSize = new EcellData();
                dSize.EntityPath = sizeData.EntityPath;
                dSize.Name = Constants.xpathSize;
                dSize.Settable = true;
                dSize.Logable = sizeData.Logable;
                dSize.Logged = sizeData.Logged;
                dSize.Value = new EcellValue(system.SizeInVolume);
                AddProperty(dSize, m_current.Type);
            }

            if (m_status == ProjectStatus.Suspended || m_status == ProjectStatus.Stepping)
            {
                UpdatePropForSimulation();
            }

            label1.Text = m_current.FullID;
        }
コード例 #26
0
ファイル: CommandManager.cs プロジェクト: ecell/ecell3-ide
            /// <summary>
            /// Sets the value of the property.
            /// </summary>
            /// <param name="propName">the property</param>
            /// <param name="value">the value</param>
            public void SetProperty(string propName, string value)
            {
                //
                // Get a current EcellObject.
                //
                this.RefinedEcellObject();
                string propertyName = propName;
                //
                // Set.
                //
                if (this.m_ecellObject == null)
                    return;
                if (this.m_ecellObject.Value == null || this.m_ecellObject.Value.Count <= 0)
                    return;

                EcellData data = m_ecellObject.GetEcellData(propertyName);
                // Add new parameter.
                if (data == null)
                {
                    string fullPN = Util.BuildFullPN(this.m_ecellObject.FullID, propertyName);
                    EcellData newData
                        = new EcellData(
                            propertyName,
                            new EcellValue(Convert.ToDouble(value)),
                            fullPN);
                    newData.Logable = true;
                    this.m_ecellObject.Value.Add(newData);
                }
                // Update current parameter.
                else if (data.Name.Equals(propertyName))
                {
                    if (!data.Settable)
                    {
                        throw new EcellException(string.Format(MessageResources.ErrSetProp,
                            new object[] { propertyName }));
                    }
                    else if (data.Name.Equals(Constants.xpathVRL))
                    {
                        List<EcellReference> list = EcellReference.ConvertFromString(value);
                        string path = this.m_fullID.Split(Constants.delimiterColon.ToCharArray())[1];
                        // Normalize
                        foreach (EcellReference er in list)
                        {
                            Util.NormalizeVariableReference(er, path);
                        }
                        data.Value = EcellReference.ConvertToEcellValue(list);
                    }
                    else if (data.Name.Equals(EcellSystem.SIZE))
                    {
                        data.Value = new EcellValue(Convert.ToDouble(value));
                        string systemID = m_ecellObject.ParentSystemID;
                        EcellObject sysObj = m_cManager.DataManager.GetEcellObject(m_ecellObject.ModelID,
                            systemID, Constants.xpathSystem);
                        ((EcellSystem)sysObj).SizeInVolume = Convert.ToDouble(value);
                    }
                    else if (data.Value.IsDouble)
                    {
                        data.Value = new EcellValue(Convert.ToDouble(value));
                    }
                    else if (data.Value.IsInt)
                    {
                        data.Value = new EcellValue(Convert.ToInt32(value));
                    }
                    else if (data.Value.IsString)
                    {
                        data.Value = new EcellValue(value);
                    }
                }
                m_cManager.DataManager.DataChanged(
                        this.m_ecellObject.ModelID,
                        this.m_ecellObject.Key,
                        this.m_ecellObject.Type,
                            this.m_ecellObject);
            }
コード例 #27
0
ファイル: PropertyWindow.cs プロジェクト: ecell/ecell3-ide
        /// <summary>
        /// Add the property to PropertyWindow.
        /// </summary>
        /// <param name="d">EcellData of property.</param>
        /// <param name="type">Type of property.</param>
        /// <returns>Row in DataGridView.</returns>
        DataGridViewRow AddProperty(EcellData d, string type)
        {
            DataGridViewRow row = new DataGridViewRow();
            DataGridViewTextBoxCell propNameCell = new DataGridViewTextBoxCell();
            DataGridViewCell propValueCell;
            propNameCell.Value = d.Name;
            row.Cells.Add(propNameCell);
            if (m_propDic == null || m_current.Type != Constants.xpathProcess
                || m_propDic.ContainsKey(d.Name))
            {
                propNameCell.Style.BackColor = Color.LightGray;
                propNameCell.Style.SelectionBackColor = Color.LightGray;
                propNameCell.ReadOnly = true;
            }
            else
            {
                propNameCell.ReadOnly = false;
                propNameCell.Style.BackColor = SystemColors.Window;
                propNameCell.Style.ForeColor = SystemColors.WindowText;
                propNameCell.Style.SelectionBackColor = SystemColors.Highlight;
                propNameCell.Style.SelectionForeColor = SystemColors.HighlightText;
            }

            if (d.Value == null) return null;

            if (d.Name == Constants.xpathExpression)
            {
                propValueCell = new DataGridViewOutOfPlaceEditableCell();
                propValueCell.Value = (string)d.Value;
                ((DataGridViewOutOfPlaceEditableCell)propValueCell).OnOutOfPlaceEditRequested =
                    delegate(DataGridViewOutOfPlaceEditableCell c)
                    {
                        string retval = ShowFormulatorDialog(c.Value == null ? "" : c.Value.ToString());
                        if (retval != null)
                        {
                            propValueCell.Value = retval;
                            UpdateExpression(retval);
                            return true;
                        }
                        return false;
                    };
            }
            else if (d.Name == Constants.xpathVRL)
            {
                propValueCell = new DataGridViewLinkCell();
                propValueCell.Value = MessageResources.LabelEdit;
            }
            else if (d.Name == Constants.xpathStepperID)
            {
                propValueCell = new DataGridViewComboBoxCell();
                bool isexist = false;
                string stepperName = d.Value.ToString();
                foreach (EcellObject obj in m_env.DataManager.GetStepper(m_current.ModelID))
                {
                    if (!string.IsNullOrEmpty(stepperName) &&
                        stepperName.Equals(obj.Key))
                    {
                        isexist = true;
                    }
                    ((DataGridViewComboBoxCell)propValueCell).Items.Add(obj.Key);
                }
                if (isexist)
                    propValueCell.Value = d.Value.ToString();
                m_stepperIDComboBox = (DataGridViewComboBoxCell)propValueCell;
            }
            else
            {
                propValueCell = new DataGridViewTextBoxCell();
                if (d.Value.IsDouble)
                {
                    propValueCell.Value = ((double)d.Value).ToString(m_env.DataManager.DisplayStringFormat);
                }
                else
                {
                    propValueCell.Value = (string)d.Value;
                }
            }
            row.Cells.Add(propValueCell);
            m_dgv.Rows.Add(row);

            if (d.Settable && !d.Name.Equals(Constants.xpathVRL))
            {
                propValueCell.ReadOnly = false;
            }
            else
            {
                propValueCell.ReadOnly = true;
                propValueCell.Style.ForeColor = SystemColors.GrayText;
            }
            propValueCell.Tag = d;

            return row;
        }
コード例 #28
0
 /// <summary>
 /// Check whether the number of bracket is correct.
 /// </summary>
 /// <param name="obj">The object to be checked.</param>
 /// <param name="l_data">The data to be checked.</param>
 private void CheckParentheses(EcellObject obj, EcellData l_data)
 {
     Regex regBrackets = new Regex("[\\(\\)]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
     Match matchBrackets = null;
     int leftBracketsCount = 0;
     int rightBracketsCount = 0;
     for (matchBrackets = regBrackets.Match((string)l_data.Value);
         matchBrackets.Success; matchBrackets = matchBrackets.NextMatch())
     {
         if (((string)l_data.Value)[matchBrackets.Groups[0].Index] == '(')
         {
             leftBracketsCount++;
         }
         else
         {
             rightBracketsCount++;
         }
     }
     if (leftBracketsCount != rightBracketsCount)
     {
         m_errorList.Add(new ObjectPropertyReport(
             MessageType.Error,
             MessageResources.ErrBrackets,
             Constants.groupDebug,
             obj,
             l_data.Name
         ));
         return;
     }
 }
コード例 #29
0
ファイル: TestUtil.cs プロジェクト: ecell/ecell3-ide
        public void TestDoesActivityChange()
        {
            EcellObject ngObj = EcellObject.CreateObject("Model", "/S0", "System", "System", new List<EcellData>());
            EcellObject noldObj = EcellObject.CreateObject("Model", "/S0:P", Constants.xpathProcess, "ExpressionFluxProcess", new List<EcellData>());
            EcellObject nnewObj = EcellObject.CreateObject("Model", "/S0:P", Constants.xpathProcess, "ExpressionFluxProcess", new List<EcellData>());
            EcellData d1 = new EcellData(Constants.xpathActivity, new EcellValue(1.0), "Process:/S0:P");
            EcellData d2 = new EcellData(Constants.xpathActivity, new EcellValue(2.0), "Process:/S0:P");
            List<EcellData> l1 = new List<EcellData>();
            List<EcellData> l2 = new List<EcellData>();
            l1.Add(d1);
            l2.Add(d2);
            EcellObject ooldObj = EcellObject.CreateObject("Model", "/S0:P", Constants.xpathProcess, "ExpressionFluxProcess", l1);
            EcellObject onewObj = EcellObject.CreateObject("Model", "/S0:P", Constants.xpathProcess, "ExpressionFluxProcess", l2);

            // ok
            bool res = Util.DoesActivityChange(ooldObj, ooldObj);
            Assert.IsFalse(res, "DoesActivityChange is unexpected value.");
            res = Util.DoesActivityChange(ooldObj, onewObj);
            Assert.IsTrue(res, "DoesActivityChange is unexpected value.");
            res = Util.DoesActivityChange(noldObj, onewObj);
            Assert.IsTrue(res, "DoesActivityChange is unexpected value.");
            res = Util.DoesActivityChange(ooldObj, nnewObj);
            Assert.IsTrue(res, "DoesActivityChange is unexpected value.");

            // ng
            try
            {
                Util.DoesActivityChange(ngObj, onewObj);
                Assert.Fail();
            }
            catch (Exception)
            {
            }

            try
            {
                Util.DoesActivityChange(ooldObj, ngObj);
                Assert.Fail();
            }
            catch (Exception)
            {
            }
        }
コード例 #30
0
ファイル: EcellObject.cs プロジェクト: ecell/ecell3-ide
 /// <summary>
 /// Set EcellValue
 /// </summary>
 /// <param name="name">the property name.</param>
 /// <param name="value">Value object.</param>
 public void SetEcellValue(string name, EcellValue value)
 {
     foreach (EcellData d in Value)
     {
         if (d.Name == name)
         {
             d.Value = value;
             return;
         }
     }
     string entytyPath = m_type + ":" + ParentSystemID + ":" + LocalID + ":" + name;
     EcellData data = new EcellData(name, value, entytyPath);
     m_ecellDatas.Add(data);
 }