Ejemplo n.º 1
0
 /// <summary>
 /// Update the initial condition of new object.
 /// </summary>
 /// <param name="oldObj">the old object.</param>
 /// <param name="newObj">the new object.</param>
 public void UpdateInitialCondition(EcellObject oldObj, EcellObject newObj)
 {
     string modelID = oldObj.ModelID;
     foreach (EcellData oldData in oldObj.Value)
     {
         EcellData newData = newObj.GetEcellData(oldData.Name);
         if (newData == null)
             continue;
         string oldPath = oldData.EntityPath;
         string newPath = newData.EntityPath;
         foreach (string simParam in InitialCondition.Keys)
         {
             if (InitialCondition[simParam][modelID].ContainsKey(oldPath))
             {
                 InitialCondition[simParam][modelID][newPath] =
                     InitialCondition[simParam][modelID][oldPath];
                 InitialCondition[simParam][modelID].Remove(oldPath);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void CheckLoggerData(EcellObject oldObj, EcellObject newObj)
        {
            List<LoggerEntry> entList = m_env.LoggerManager.GetLoggerEntryForObject(oldObj.Key, oldObj.Type);

            foreach (EcellData nd in newObj.Value)
            {
                EcellData od = oldObj.GetEcellData(nd.Name);
                if (od != null && od.Logged == nd.Logged)
                    continue;
                if (nd.Logged)
                {
                    m_env.LoggerManager.AddLoggerEntry(newObj.ModelID, newObj.Key, newObj.Type, nd.EntityPath);
                }
                else
                {
                    if (od != null)
                        m_env.LoggerManager.LoggerRemoved(new LoggerEntry(newObj.ModelID, newObj.Key, newObj.Type, nd.EntityPath));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check whether the properties of this object is added or deleted.
        /// </summary>
        /// <param name="oldObj">the old object.</param>
        /// <param name="newObj">the new object.</param>
        /// <returns>if changed, return true.</returns>
        private bool IsCheckNecessary(EcellObject oldObj, EcellObject newObj)
        {
            if (oldObj.Value.Count > newObj.Value.Count)
                return true;

            foreach (EcellData d in oldObj.Value)
            {
                if (newObj.GetEcellData(d.Name) == null)
                    return true;
            }

            return false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Check the deleted property in paramater or observed data.
        /// </summary>
        /// <param name="oldObj">the old object.</param>
        /// <param name="newObj">the new object.</param>
        private void CheckDeleteParameterData(EcellObject oldObj, EcellObject newObj)
        {
            List<string> delList = new List<string>();
            foreach (EcellData oldData in oldObj.Value)
            {
                if (newObj.GetEcellData(oldData.Name) == null)
                    delList.Add(oldData.EntityPath);
            }

            foreach (string entPath in delList)
            {
                EcellParameterData p = GetParameterData(entPath);
                if (p != null)
                    RemoveParameterData(p);
                EcellObservedData o = GetObservedData(entPath);
                if (o != null )
                    RemoveObservedData(o);
            }

            foreach (string paramID in m_currentProject.InitialCondition.Keys)
            {
                foreach (string modelID in m_currentProject.InitialCondition[paramID].Keys)
                {
                    foreach (string entPath in delList)
                    {
                        if (m_currentProject.InitialCondition[paramID][modelID].ContainsKey(entPath))
                            m_currentProject.InitialCondition[paramID][modelID].Remove(entPath);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <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;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create the new row for Object.
 /// </summary>
 /// <param name="obj">the inserted object.</param>
 /// <returns>the inserted row.</returns>
 private DataGridViewRow CreateRow(EcellObject obj)
 {
     DataGridViewRow rs = new DataGridViewRow();
     {
         DataGridViewImageCell c = new DataGridViewImageCell();
         c.Value = GetIconImage(obj);
         rs.Cells.Add(c);
         c.ReadOnly = true;
     }
     {
         DataGridViewTextBoxCell c = new DataGridViewTextBoxCell();
         c.Value = obj.Classname;
         rs.Cells.Add(c);
         c.ReadOnly = true;
     }
     {
         DataGridViewTextBoxCell c = new DataGridViewTextBoxCell();
         c.Value = obj.Key;
         rs.Cells.Add(c);
         c.ReadOnly = true;
     }
     {
         DataGridViewTextBoxCell c = new DataGridViewTextBoxCell();
         EcellData d = obj.GetEcellData("Name");
         // for loading the project include the process not in DM directory.
         if (d == null)
             c.Value = "";
         else
             c.Value = d.Value.ToString();
         rs.Cells.Add(c);
         c.ReadOnly = true;
     }
     rs.Tag = obj;
     return rs;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// The event sequence on changing value of data at other plugin.
 /// </summary>
 /// <param name="modelID">The model ID before value change.</param>
 /// <param name="key">The ID before value change.</param>
 /// <param name="type">The data type before value change.</param>
 /// <param name="data">Changed value of object.</param>
 public void DataChanged(string modelID, string key, string type, EcellObject data)
 {
     if (key != data.Key)
     {
         DataDelete(modelID, key, type);
         DataAdd(data);
         AddSelect(data.ModelID, data.Key, data.Type);
         return;
     }
     DataGridViewRow r = SearchIndex(type, key);
     if (r != null)
     {
         r.Tag = data;
         r.Cells[IndexType].Value = GetIconImage(data);
         r.Cells[IndexClass].Value = data.Classname;
         EcellData d = data.GetEcellData("Name");
         r.Cells[IndexName].Value = d != null ? d.Value.ToString() : "";
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Get the data string from entity name.
        /// </summary>
        /// <param name="name">The entity name.</param>
        /// <param name="obj">The searched object.</param>
        /// <returns>the data string.</returns>
        private string GetData(string name, EcellObject obj)
        {
            if (name.Equals(s_indexType))
            {
                return obj.Type;
            }
            else if (name.Equals(s_indexID))
            {
                return obj.Key;
            }
            else if (name.Equals(s_indexModel))
            {
                return obj.ModelID;
            }
            else if (name.Equals(s_indexClass))
            {
                return obj.Classname;
            }
            else if (name.Equals(s_indexName))
            {
                EcellData data = obj.GetEcellData("Name");
                return data != null ? (string)data.Value : "";
            }
            else if (name.Equals(s_indexStepper))
            {
                foreach (EcellData d in obj.Value)
                {
                    if (d.Name.Equals(Constants.xpathStepperID))
                        return (string)d.Value;
                }
            }
            else if (name.Equals(s_indexSize))
            {
                EcellSystem data = obj as EcellSystem;
                return data.SizeInVolume.ToString(m_env.DataManager.DisplayStringFormat);
            }
            else
            {
                foreach (EcellData d in obj.Value)
                {
                    if (name.Equals(d.Name))
                    {
                        if (d.Value.IsDouble)
                            return ((double)d.Value).ToString(m_env.DataManager.DisplayStringFormat);
                        return (string)d.Value;
                    }
                }
            }

            return "";
        }