Exemplo n.º 1
0
 /// <summary>
 /// The constructor for UpdateStepperAction with initial parameters.
 /// </summary>
 /// <param name="newID">The updated stepper ID.</param>
 /// <param name="orgID">The original stepper ID.</param>
 /// <param name="newStepper">The updated stepper.</param>
 /// <param name="oldStepper">The old stepper.</param>
 public ChangeStepperAction(string newID, string orgID, EcellObject newStepper, EcellObject oldStepper)
 {
     m_newID = newID;
     m_orgID = orgID;
     m_newStepper = newStepper;
     m_oldStepper = oldStepper;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Stores the "EcellObject"
 /// </summary>
 /// <param name="simulator">The "simulator"</param>
 /// <param name="dmm">The "DMDescriptorKeeper"</param>
 /// <param name="ecellObject">The stored "EcellObject"</param>
 /// <param name="initialCondition">The initial condition.</param>
 internal static void DataStored(
     WrappedSimulator simulator,
     DMDescriptorKeeper dmm,
     EcellObject ecellObject,
     Dictionary<string, double> initialCondition)
 {
     if (ecellObject.Type.Equals(Constants.xpathStepper))
     {
         DataStored4Stepper(simulator, dmm, ecellObject);
     }
     else if (ecellObject.Type.Equals(Constants.xpathSystem))
     {
         DataStored4System(
                 simulator,
                 ecellObject,
                 initialCondition);
     }
     else if (ecellObject.Type.Equals(Constants.xpathProcess))
     {
         DataStored4Process(
                 simulator,
                 dmm,
                 ecellObject,
                 initialCondition);
     }
     else if (ecellObject.Type.Equals(Constants.xpathVariable))
     {
         DataStored4Variable(
                 simulator,
                 ecellObject,
                 initialCondition);
     }
     //
     // 4 children
     //
     if (ecellObject.Children != null)
     {
         foreach (EcellObject childEcellObject in ecellObject.Children)
             DataStored(simulator, dmm, childEcellObject, initialCondition);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add System to this project.
 /// </summary>
 /// <param name="system">the system object.</param>
 public void AddSystem(EcellObject system)
 {
     m_systemDic[system.ModelID].Add(system);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Stores the "EcellObject" 4 the "System".
        /// </summary>
        /// <param name="simulator">The simulator</param>
        /// <param name="ecellObject">The stored "System"</param>
        /// <param name="initialCondition">The initial condition.</param>
        internal static void DataStored4System(
            WrappedSimulator simulator,
            EcellObject ecellObject,
            Dictionary<string, double> initialCondition)
        {
            // Creates an entityPath.
            string parentPath = ecellObject.ParentSystemID;
            string childPath = ecellObject.LocalID;
            string key = Constants.xpathSystem + Constants.delimiterColon +
                parentPath + Constants.delimiterColon +
                childPath;
            // Property List
            IList<string> wrappedPolymorph = simulator.GetEntityPropertyList(key);
            //
            // Checks the stored "EcellData"
            //
            List<EcellData> systemEcellDataList = new List<EcellData>();
            Dictionary<string, EcellData> storedEcellDataDic
                    = new Dictionary<string, EcellData>();
            if (ecellObject.Value != null && ecellObject.Value.Count > 0)
            {
                foreach (EcellData storedEcellData in ecellObject.Value)
                {
                    storedEcellDataDic[storedEcellData.Name] = storedEcellData;
                    systemEcellDataList.Add(storedEcellData);

                }
            }
            foreach (string name in wrappedPolymorph)
            {
                string entityPath = key + Constants.delimiterColon + name;
                PropertyAttributes flag = simulator.GetEntityPropertyAttributes(entityPath);

                if (!flag.Gettable)
                {
                    continue;
                }

                object value = null;
                if (name.Equals(Constants.xpathSize))
                {
                    value = new EcellValue(EcellSystem.DefaultSize);
                }
                else
                {
                    try
                    {
                        value = new EcellValue(simulator.GetEntityProperty(entityPath));
                    }
                    catch (WrappedException ex)
                    {
                        Trace.WriteLine(ex);
                        if (storedEcellDataDic.ContainsKey(name))
                        {
                            IEnumerable val = storedEcellDataDic[name].Value as IEnumerable;
                            object firstItem = null;
                            {
                                IEnumerator i = val.GetEnumerator();
                                if (i.MoveNext())
                                    firstItem = i.Current;
                            }
                            if (firstItem is IEnumerable)
                            {
                                value = val;
                            }
                            else
                            {
                                value = firstItem;
                            }
                        }
                        else
                        {
                            value = "";
                        }
                    }
                }

                EcellData ecellData = CreateEcellData(name, new EcellValue(value), entityPath, flag);
                if (ecellData.Value != null)
                {
                    ecellData.Logable = ecellData.Value.IsDouble;
                }
                if (storedEcellDataDic.ContainsKey(name))
                {
                    ecellData.Logged = storedEcellDataDic[name].Logged;
                    systemEcellDataList.Remove(storedEcellDataDic[name]);
                }
                systemEcellDataList.Add(ecellData);
            }

            ecellObject.SetEcellDatas(systemEcellDataList);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stores the "EcellObject" 4 the "Process".
        /// </summary>
        /// <param name="simulator">The simulator</param>
        /// <param name="dmm">The "DMDescriptorKeeper"</param>
        /// <param name="ecellObject">The stored "Process"</param>
        /// <param name="initialCondition">The initial condition.</param>
        internal static void DataStored4Process(
            WrappedSimulator simulator,
            DMDescriptorKeeper dmm,
            EcellObject ecellObject,
            Dictionary<string, double> initialCondition)
        {
            string key = ecellObject.FullID;
            IList<string> wrappedPolymorph = null;
            try
            {
                wrappedPolymorph = simulator.GetEntityPropertyList(key);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                return;
            }
            //
            // Checks the stored "EcellData"
            //
            List<EcellData> processEcellDataList = new List<EcellData>();
            Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>();

            if (ecellObject.Value != null && ecellObject.Value.Count > 0)
            {
                foreach (EcellData storedEcellData in ecellObject.Value)
                {
                    storedEcellDataDic[storedEcellData.Name] = storedEcellData;
                    processEcellDataList.Add(storedEcellData);

                }
            }
            //
            // Stores the "EcellData"
            //
            foreach (string name in wrappedPolymorph)
            {
                string entityPath = Util.BuildFullPN(key, name);

                PropertyAttributes flag = simulator.GetEntityPropertyAttributes(entityPath);
                if (!flag.Gettable)
                {
                    continue;
                }
                EcellValue value = null;

                if (name == Constants.xpathVRL)
                {
                    // Won't restore the variable reference list from the simulator's corresponding
                    // object.
                    if (storedEcellDataDic.ContainsKey(name))
                        value = storedEcellDataDic[name].Value;
                    else
                        value = new EcellValue(new List<object>());
                }
                else if (name == Constants.xpathActivity || name == Constants.xpathMolarActivity)
                {
                    value = new EcellValue(0.0);
                }
                else
                {
                    try
                    {
                        value = new EcellValue(simulator.GetEntityProperty(entityPath));
                        if (dmm.ContainsDescriptor(ecellObject.Type, ecellObject.Classname))
                        {
                            DMDescriptor desc = dmm.GetDMDescriptor(ecellObject.Type, ecellObject.Classname);
                            if (desc.ContainsProperty(name))
                            {
                                PropertyDescriptor prop = desc[name];
                                if (prop.DefaultValue.Type == EcellValueType.List && !value.IsList)
                                    value = new EcellValue(new List<EcellValue>());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex);
                        value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name);
                    }
                }
                EcellData ecellData = CreateEcellData(name, value, entityPath, flag);
                if (ecellData.Value != null)
                {
                    ecellData.Logable = ecellData.Value.IsDouble &&
                        (ecellData.Settable == false || ecellData.Saveable == false);

                }

                if (storedEcellDataDic.ContainsKey(name))
                {
                    ecellData.Logged = storedEcellDataDic[name].Logged;
                    processEcellDataList.Remove(storedEcellDataDic[name]);
                }
                processEcellDataList.Add(ecellData);

            }
            ecellObject.SetEcellDatas(processEcellDataList);
        }
Exemplo n.º 6
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 (m_current == null)
         return;
     if (m_isChanging)
     {
         if (m_current.Key == key)
         {
             m_current = data;
             UpdateProperties();
         }
         return;
     }
     if (m_current.ModelID == modelID && m_current.Key == key && m_current.Type == type)
     {
         m_current = data;
         ReloadProperties();
     }
 }
Exemplo n.º 7
0
 /// <summary>
 ///  When change system status, change menu enable/disable.
 /// </summary>
 /// <param name="type">System status.</param>
 public void ChangeStatus(ProjectStatus type)
 {
     if (type == ProjectStatus.Running)
     {
         m_dgv.ReadOnly = true;
     //                m_dgv.Enabled = false;
         m_time.Enabled = true;
         m_time.Start();
     }
     else if (type == ProjectStatus.Suspended)
     {
         m_dgv.ReadOnly = false;
     //                m_dgv.Enabled = true;
         m_time.Enabled = false;
         m_time.Stop();
         try
         {
             UpdatePropForSimulation();
             ResetReadOnly();
         }
         catch (Exception)
         {
             // ���̃v���O�C���Ńf�[�^��ҏW������
             // �V�~�����[�V�������ُ�I���������f�[�^��擾�ł��Ȃ��������߁B
             // ���̃v���O�C���ŃG���[���b�Z�[�W���\�������̂�
             // �����ł͏o���Ȃ��悤�ɂ���B
         }
     }
     else if (type == ProjectStatus.Loaded)
     {
     //                m_dgv.Enabled = true;
         m_dgv.ReadOnly = false;
         if (m_status == ProjectStatus.Running || m_status == ProjectStatus.Suspended || m_status == ProjectStatus.Stepping)
         {
             m_time.Enabled = false;
             m_time.Stop();
             if (m_current != null)
                 m_current = m_env.DataManager.GetEcellObject(m_current.ModelID, m_current.Key, m_current.Type);
             ResetProperty();
             ResetReadOnly();
         }
     }
     else if (type == ProjectStatus.Uninitialized)
     {
         m_dgv.ReadOnly = true;
     //                m_dgv.Enabled = false;
     }
     else if (type == ProjectStatus.Stepping)
     {
         m_dgv.ReadOnly = false;
     //                m_dgv.Enabled = true;
         try
         {
             UpdatePropForSimulation();
             ResetReadOnly();
         }
         catch (Exception)
         {
             // ���̃v���O�C���Ńf�[�^��ҏW������
             // �V�~�����[�V�������ُ�I���������f�[�^��擾�ł��Ȃ��������߁B
             // ���̃v���O�C���ŃG���[���b�Z�[�W���\�������̂�
             // �����ł͏o���Ȃ��悤�ɂ���B
         }
     }
     m_status = type;
     m_dgv.ReadOnly = false;
 }
Exemplo n.º 8
0
 /// <summary>
 /// The constructor for DataChangeAction with initial parameters.
 /// </summary>
 /// <param name="paramID">A parameter ID.</param>
 /// <param name="oldObj">An object before changing.</param>
 /// <param name="newObj">An object after changing.</param>
 public DataChangeAction(string paramID, EcellObject oldObj, EcellObject newObj)
 {
     m_paramID = paramID;
     m_oldObj = oldObj.Clone();
     m_newObj = newObj.Clone();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Add the object.
 /// </summary>
 /// <param name="data">the added object.</param>
 public override void DataAdd(EcellObject data)
 {
     m_editCount++;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor with the initial parameters.
 /// </summary>
 /// <param name="type">the type of message.</param>
 /// <param name="message">the message string.</param>
 /// <param name="group">the group string.</param>
 /// <param name="obj">the object of message.</param>
 /// <param name="propertyName">the proerty name.</param>
 public ObjectPropertyReport(MessageType type, string message, 
     string group, EcellObject obj, string propertyName)
     : base(type, message, group, obj)
 {
     m_propName = propertyName;
 }
Exemplo n.º 11
0
 private void AddIntoDictionary(SortedDictionary<float, List<EcellObject>> dict,
     float posValue,
     EcellObject node)
 {
     if (dict == null)
         return;
     if (dict.ContainsKey(posValue))
         dict[posValue].Add(node);
     else
     {
         List<EcellObject> newDict = new List<EcellObject>();
         newDict.Add(node);
         dict.Add(posValue, newDict);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Set initial condition of new object.
        /// </summary>
        /// <param name="newobj">the new object.</param>
        public void SetInitialCondition(EcellObject newobj)
        {
            EcellObject defaultObj = GetEcellObject(newobj.ModelID,
                newobj.Type, newobj.Key, true);

            foreach (EcellData newData in newobj.Value)
            {
                EcellData defaultData = defaultObj.GetEcellData(newData.Name);
                if (defaultData == null)
                    continue;
                defaultData.Logged = newData.Logged;
                if (!newData.Settable || (newData.Value == null || (!newData.Value.IsDouble && !newData.Value.IsInt)))
                {
                    defaultObj.RemoveEcellValue(newData.Name);
                    defaultObj.Value.Add(newData);
                    continue;
                }
                double newProp = Convert.ToDouble(newData.Value.Value.ToString());
                double defaultProp = Convert.ToDouble(defaultData.Value.Value.ToString());
                if (newProp != defaultProp)
                {
                    InitialCondition[Info.SimulationParam][newobj.ModelID][newData.EntityPath] = newProp;
                }
                else
                {
                    InitialCondition[Info.SimulationParam][newobj.ModelID].Remove(newData.EntityPath);
                }
            }

            defaultObj.Layout = newobj.Layout.Clone();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Delete System.
 /// </summary>
 /// <param name="system">the system object.</param>
 public void DeleteSystem(EcellObject system)
 {
     string type, ekey, param;
     m_systemDic[system.ModelID].Remove(system);
     // Delete Simulation parameter.
     foreach (string keyParamID in m_initialCondition.Keys)
     {
         foreach (string delModel in m_initialCondition[keyParamID].Keys)
         {
             Debug.Assert(system.Type == Constants.xpathSystem);
             string delKey = system.Key;
             List<String> delKeyList = new List<string>();
             foreach (string entKey in m_initialCondition[keyParamID][delModel].Keys)
             {
                 Util.ParseFullPN(entKey, out type, out ekey, out param);
                 if (ekey.Equals(delKey) || ekey.StartsWith(delKey + "/") || ekey.StartsWith(delKey + ":"))
                     delKeyList.Add(entKey);
             }
             foreach (string entKey in delKeyList)
             {
                 m_initialCondition[keyParamID][delModel].Remove(entKey);
             }
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Delete the initial condition of object.
 /// </summary>
 /// <param name="obj">the deleted object.</param>
 public void DeleteInitialCondition(EcellObject obj)
 {
     string modelID = obj.ModelID;
     foreach (String simParam in InitialCondition.Keys)
     {
         foreach (EcellData d in obj.Value)
         {
             if (InitialCondition[simParam][modelID].ContainsKey(d.EntityPath))
                 InitialCondition[simParam][modelID].Remove(d.EntityPath);
         }
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Delete Entity.
        /// </summary>
        /// <param name="entity">the entity object.</param>
        public void DeleteEntity(EcellObject entity)
        {
            // set param
            string model = entity.ModelID;
            string key = entity.Key;
            string sysKey = entity.ParentSystemID;
            string type = entity.Type;
            // delete entity
            foreach (EcellObject system in m_systemDic[entity.ModelID])
            {
                if (!system.Key.Equals(sysKey))
                    continue;
                foreach (EcellObject child in system.Children)
                {
                    if (!child.Key.Equals(key) || !child.Type.Equals(type))
                        continue;
                    system.Children.Remove(child);
                    break;
                }
            }

            // Delete Simulation parameter.
            foreach (string keyParameterID in m_initialCondition.Keys)
            {
                Dictionary<string, double> condition = m_initialCondition[keyParameterID][model];
                foreach (EcellData data in entity.Value)
                {
                    if (!data.Settable)
                        continue;
                    if (!condition.ContainsKey(data.EntityPath))
                        continue;
                    condition.Remove(data.EntityPath);
                }
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Notify DataAdd event to outside.
 /// </summary>
 /// <param name="eo">Added EcellObject</param>
 /// <param name="isAnchor">Whether this action is an anchor or not</param>
 public void NotifyDataAdd(EcellObject eo, bool isAnchor)
 {
     try
     {
         m_window.NotifyDataAdd(eo, isAnchor);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Notify DataChanged event to outside (PathwayControl -> PathwayWindow -> DataManager)
 /// To notify position or size change.
 /// </summary>
 /// <param name="oldKey">the key before adding.</param>
 /// <param name="eo">Changed EcellObject.</param>
 /// <param name="isRecorded">Whether to record this change.</param>
 /// <param name="isAnchor">Whether this action is an anchor or not.</param>
 public void NotifyDataChanged(
     string oldKey,
     EcellObject eo,
     bool isRecorded,
     bool isAnchor)
 {
     m_unreachedFlag = true;
     m_window.NotifyDataChanged(oldKey, eo, isRecorded, isAnchor);
     if (m_unreachedFlag)
         throw new PathwayException("Unreached DataChangedEvent.");
 }
Exemplo n.º 18
0
 /// <summary>
 /// Change the property of object.
 /// </summary>
 /// <param name="modelID">the model ID of changed object.</param>
 /// <param name="key">the key of changed object.</param>
 /// <param name="type">the type of changed object.</param>
 /// <param name="data">the changed object.</param>
 public override void DataChanged(string modelID, string key, string type, EcellObject data)
 {
     m_editCount++;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Change the property of data. 
 /// </summary>
 /// <param name="modelID">the modelID of object changed property.</param>
 /// <param name="key">the key of object changed property.</param>
 /// <param name="obj">the object changed property.</param>
 private bool NotifyDataChanged(string modelID, string key, EcellObject obj)
 {
     bool changeSuccess = true;
     m_isChanging = true;
     try
     {
         m_env.DataManager.DataChanged(modelID, key, obj.Type, obj);
         if (obj != m_current)
         {
             if (m_status == ProjectStatus.Suspended || m_status == ProjectStatus.Stepping)
             {
                 UpdatePropForSimulation();
             }
             else
             {
                 UpdateProperties();
             }
             changeSuccess = false;
         }
     }
     finally
     {
         m_isChanging = false;
     }
     return changeSuccess;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Notify DataDelete event to outsite.
 /// </summary>
 /// <param name="eo">the deleted object.</param>
 /// <param name="isAnchor">the type of deleted object.</param>
 public void NotifyDataDelete(EcellObject eo, bool isAnchor)
 {
     try
     {
         m_window.NotifyDataDelete(eo.ModelID, eo.Key, eo.Type, isAnchor);
     }
     catch (Exception e)
     {
         Util.ShowErrorDialog(e.Message);
         Debug.WriteLine(e.Message);
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// The event sequence on closing project.
 /// </summary>
 public void Clear()
 {
     m_current = null;
     ReloadProperties();
     label1.Text = "";
 }
Exemplo n.º 22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="eo"></param>
 public void NotifySetPosition(EcellObject eo)
 {
     m_window.NotifySetPosition(eo);
 }
Exemplo n.º 23
0
        /// <summary>
        /// The event sequence on changing selected object at other plugin.
        /// </summary>
        /// <param name="modelID">Selected the model ID.</param>
        /// <param name="key">Selected the ID.</param>
        /// <param name="type">Selected the data type.</param>
        public void SelectChanged(string modelID, string key, string type)
        {
            // When called with illegal arguments, this method will do nothing;
            if (String.IsNullOrEmpty(modelID) || String.IsNullOrEmpty(key))
            {
                return;
            }

            EcellObject obj = GetData(modelID, key, type);
            if (obj == null) return;
            m_current = obj;
            Console.WriteLine("Select change" + " : " + type + " : " + key);

            ReloadProperties();
        }
Exemplo n.º 24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="eo"></param>
        public void SetPosition(EcellObject eo)
        {
            // Select Canvas
            if (m_canvas == null)
                return;
            // If case SystemSize
            if (eo.Type == Constants.xpathVariable)
            {
                string superSystemPath, localID;
                Util.ParseEntityKey(eo.Key, out superSystemPath, out localID);
                if (localID == "SIZE")
                    return;
            }

            // Select changed object.
            PPathwayObject obj = m_canvas.GetObject(eo.Key, eo.Type);
            if (obj == null)
                return;

            // Change data.
            obj.EcellObject = eo;
            m_canvas.SetLayer(obj, eo.Layer);
            obj.RefreshView();
        }
Exemplo n.º 25
0
 /// <summary>
 /// Stores the "EcellObject" 4 the "Stepper".
 /// </summary>
 /// <param name="simulator">The simulator</param>
 /// <param name="dmm">The "DynamicModuleManager"</param>
 /// <param name="ecellObject">The stored "Stepper"</param>
 internal static void DataStored4Stepper(
     WrappedSimulator simulator,
     DMDescriptorKeeper dmm,
     EcellObject ecellObject)
 {
     string key = Constants.xpathStepper + Constants.delimiterColon + Constants.delimiterColon + ecellObject.Key;
     List<EcellData> stepperEcellDataList = new List<EcellData>();
     IList<string> wrappedPolymorph = null;
     //
     // Property List
     //
     try
     {
         wrappedPolymorph = simulator.GetStepperPropertyList(ecellObject.Key);
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.StackTrace);
         return;
     }
     //
     // Sets the class name.
     //
     if (string.IsNullOrEmpty(ecellObject.Classname))
     {
         ecellObject.Classname = simulator.GetStepperClassName(ecellObject.Key);
     }
     //
     // Checks the stored "EcellData"
     //
     Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>();
     if (ecellObject.Value != null && ecellObject.Value.Count > 0)
     {
         foreach (EcellData storedEcellData in ecellObject.Value)
         {
             storedEcellDataDic[storedEcellData.Name] = storedEcellData;
             stepperEcellDataList.Add(storedEcellData);
         }
     }
     //
     // Stores the "EcellData"
     //
     foreach (string name in wrappedPolymorph)
     {
         string entityPath = key + Constants.delimiterColon + name;
         PropertyAttributes flag = simulator.GetStepperPropertyAttributes(ecellObject.Key, name);
         if (!flag.Gettable)
         {
             continue;
         }
         EcellValue value = null;
         try
         {
             object property = simulator.GetStepperProperty(ecellObject.Key, name);
             value = new EcellValue(property);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex);
             value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name);
         }
         EcellData ecellData = CreateEcellData(name, value, entityPath, flag);
         if (storedEcellDataDic.ContainsKey(name))
         {
             if (value.IsString && value.ToString().Equals(""))
             {
                 continue;
             }
             else
             {
                 stepperEcellDataList.Remove(storedEcellDataDic[name]);
             }
         }
         stepperEcellDataList.Add(ecellData);
     }
     ecellObject.SetEcellDatas(stepperEcellDataList);
 }
Exemplo n.º 26
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="varKeys"></param>
        /// <param name="obj"></param>
        private static bool ReplaceVarRef(Dictionary<string, string> varKeys, EcellObject obj)
        {
            bool flag = false;
            if (!(obj is EcellProcess))
                return flag;

            // Set VariableReferenceList.
            EcellProcess ep = (EcellProcess)obj;
            List<EcellReference> list = ep.ReferenceList;
            List<EcellReference> newlist = new List<EcellReference>();
            foreach (EcellReference er in list)
            {
                if (!varKeys.ContainsKey(er.Key))
                    continue;
                er.Key = varKeys[er.Key];
                newlist.Add(er);
                flag = true;
            }
            ep.ReferenceList = newlist;
            return flag;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Stores the "EcellObject" 4 the "Variable".
        /// </summary>
        /// <param name="simulator">The simulator</param>
        /// <param name="ecellObject">The stored "Variable"</param>
        /// <param name="initialCondition">The initial condition.</param>
        internal static void DataStored4Variable(
            WrappedSimulator simulator,
            EcellObject ecellObject,
            Dictionary<string, double> initialCondition)
        {
            string fullID = ecellObject.FullID;
            IList<string> wrappedPolymorph = simulator.GetEntityPropertyList(fullID);
            //
            // Checks the stored "EcellData"
            //
            List<EcellData> variableEcellDataList = new List<EcellData>();
            Dictionary<string, EcellData> storedEcellDataDic
                    = new Dictionary<string, EcellData>();
            if (ecellObject.Value != null && ecellObject.Value.Count > 0)
            {
                foreach (EcellData storedEcellData in ecellObject.Value)
                {
                    storedEcellDataDic[storedEcellData.Name] = storedEcellData;
                    variableEcellDataList.Add(storedEcellData);

                }
            }
            foreach (string name in wrappedPolymorph)
            {
                string entityPath = fullID + Constants.delimiterColon + name;
                PropertyAttributes flag = simulator.GetEntityPropertyAttributes(entityPath);
                if (!flag.Gettable)
                {
                    continue;
                }
                EcellValue value = GetVariableValue(simulator, name, entityPath);
                EcellData ecellData = CreateEcellData(name, value, entityPath, flag);
                if (ecellData.Value != null)
                {
                    ecellData.Logable = ecellData.Value.IsDouble;
                }
                if (storedEcellDataDic.ContainsKey(name))
                {
                    ecellData.Logged = storedEcellDataDic[name].Logged;
                    variableEcellDataList.Remove(storedEcellDataDic[name]);
                }
                variableEcellDataList.Add(ecellData);
            }
            ecellObject.SetEcellDatas(variableEcellDataList);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Add new object to this canvas.
        /// </summary>
        /// <param name="eo">EcellObject</param>
        /// <param name="isAnchor">True is default. If undo unit contains multiple actions,
        /// only the last action's isAnchor is true, the others' isAnchor is false</param>
        public void DataAdd(EcellObject eo, bool isAnchor)
        {
            // Null check.
            if (eo == null)
                return;
            // Load new project
            else if (eo.Type.Equals(EcellObject.PROJECT))
            {
                return;
            }
            // create new canvas
            else if (eo.Type.Equals(EcellObject.MODEL))
            {
                this.CreateCanvas((EcellModel)eo);
                return;
            }
            // Ignore system size.
            else if (eo.Type == Constants.xpathVariable && eo.LocalID == "SIZE")
            {
                return;
            }

            // Create PathwayObject and set to canvas.
            PPathwayObject obj = m_csManager.CreateNewComponent(eo.Type, eo.Layout.Figure);
            obj.Canvas = m_canvas;
            obj.EcellObject = eo;

            m_canvas.DataAdd(obj, eo.IsPosSet);
            NotifySetPosition(obj);

            // Update Animation.
            if (IsAnimation)
                m_animCon.SetAnimation();
        }
Exemplo n.º 29
0
 /// <summary>
 /// Show property window displayed the selected object.
 /// </summary>
 /// <param name="obj">the selected object</param>
 public void ShowPropEditWindow(EcellObject obj)
 {
     PropertyEditor.Show(m_owner.DataManager, m_owner.PluginManager, obj);
 }
Exemplo n.º 30
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="oldKey">The ID before value change.</param>
        /// <param name="type">The data type before value change.</param>
        /// <param name="eo">Changed value of object.</param>
        public void DataChanged(string modelID, string oldKey, string type, EcellObject eo)
        {
            // Select Canvas
            if (m_canvas == null)
                return;

            // Reset unreached flag.
            m_unreachedFlag = false;

            if (type.Equals(EcellObject.MODEL))
            {
                EcellModel model = (EcellModel)eo;
                m_layerView.ResetLayers(model.Layers);
                m_canvas.RefreshEdges();
                m_animCon.SetAnimationSettings((XmlElement)model.Animations);
            }

            PPathwayObject obj;
            // If case SystemSize
            if (type == Constants.xpathVariable)
            {
                if (eo.LocalID == "SIZE")
                {
                    obj = m_canvas.Systems[eo.ParentSystemID];
                    ((EcellSystem)obj.EcellObject).SizeInVolume = (double)eo.GetEcellValue("Value");
                    obj.Refresh();
                }
            }

            // Select changed object.
            obj = m_canvas.GetObject(oldKey, type);
            if (obj != null)
            {
                // Change data.
                if (!obj.Setting.Name.Equals(eo.Layout.Figure))
                    obj.Setting = m_csManager.GetSetting(eo.Type, eo.Layout.Figure);
                obj.EcellObject = eo;
                m_canvas.DataChanged(oldKey, eo.Key, obj);
            }

            // Update Animation.
            if (IsAnimation)
                m_animCon.SetAnimation();
        }